Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/dns/style.py: 38%
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, TypeVar
6T = TypeVar("T", bound="BaseStyle")
9@dataclasses.dataclass(frozen=True)
10class BaseStyle:
11 """All text styles"""
13 def replace(self: T, /, **changes) -> T:
14 return dataclasses.replace(self, **changes)
16 @classmethod
17 def from_keywords(cls: type[T], kw: dict[str, Any]) -> T:
18 ok_kw: dict[str, Any] = {}
19 for k, v in kw.items():
20 if k == "chunksize":
21 ok_kw["hex_chunk_size"] = v
22 ok_kw["base64_chunk_size"] = v
23 elif k == "separator":
24 ok_kw["hex_separator"] = v
25 ok_kw["base64_separator"] = v
26 elif hasattr(cls, k):
27 ok_kw[k] = v
28 return cls(**ok_kw)