Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/dns/style.py: 35%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license
3import dataclasses
4from typing import Any, Self
7@dataclasses.dataclass(frozen=True)
8class BaseStyle:
9 """All text styles"""
11 def replace(self: Self, /, **changes) -> Self:
12 return dataclasses.replace(self, **changes)
14 @classmethod
15 def from_keywords(cls: type[Self], kw: dict[str, Any]) -> Self:
16 ok_kw: dict[str, Any] = {}
17 for k, v in kw.items():
18 if k == "chunksize":
19 ok_kw["hex_chunk_size"] = v
20 ok_kw["base64_chunk_size"] = v
21 elif k == "separator":
22 ok_kw["hex_separator"] = v
23 ok_kw["base64_separator"] = v
24 elif hasattr(cls, k):
25 ok_kw[k] = v
26 return cls(**ok_kw)