Skip to content

Whitespaces

toolbox_pyspark.utils.whitespaces 🔗

WhitespaceChatacter dataclass 🔗

Source code in src/toolbox_pyspark/utils/whitespaces.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
@dataclass
class WhitespaceChatacter:
    name: str
    unicode: str
    ascii: int
    chr: str = field(init=False)

    def __post_init__(self) -> None:
        self.chr = chr(self.ascii)

    def __getitem__(
        self, attribute: Literal["name", "unicode", "ascii", "chr"]
    ) -> Union[str, int]:
        return getattr(self, attribute)
__init__ 🔗
__init__(name: str, unicode: str, ascii: int) -> None
name instance-attribute 🔗
name: str
unicode instance-attribute 🔗
unicode: str
ascii instance-attribute 🔗
ascii: int
chr class-attribute instance-attribute 🔗
chr: str = field(init=False)
__post_init__ 🔗
__post_init__() -> None
Source code in src/toolbox_pyspark/utils/whitespaces.py
13
14
def __post_init__(self) -> None:
    self.chr = chr(self.ascii)
__getitem__ 🔗
__getitem__(
    attribute: Literal["name", "unicode", "ascii", "chr"]
) -> Union[str, int]
Source code in src/toolbox_pyspark/utils/whitespaces.py
16
17
18
19
def __getitem__(
    self, attribute: Literal["name", "unicode", "ascii", "chr"]
) -> Union[str, int]:
    return getattr(self, attribute)

WhitespaceCharacters dataclass 🔗

Source code in src/toolbox_pyspark/utils/whitespaces.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
@dataclass
class WhitespaceCharacters:
    characters: Union[
        List[WhitespaceChatacter],
        Tuple[WhitespaceChatacter],
    ]

    def __iter__(self):
        yield from self.characters

    def to_list(
        self,
        attr: Optional[Literal["name", "unicode", "ascii", "chr"]] = None,
    ) -> List[Union[str, int, WhitespaceChatacter]]:
        return [char if attr is None else char[attr] for char in self]
__init__ 🔗
__init__(
    characters: Union[
        List[WhitespaceChatacter],
        Tuple[WhitespaceChatacter],
    ]
) -> None
characters instance-attribute 🔗
characters: Union[
    List[WhitespaceChatacter], Tuple[WhitespaceChatacter]
]
__iter__ 🔗
__iter__()
Source code in src/toolbox_pyspark/utils/whitespaces.py
29
30
def __iter__(self):
    yield from self.characters
to_list 🔗
to_list(
    attr: Optional[
        Literal["name", "unicode", "ascii", "chr"]
    ] = None
) -> List[Union[str, int, WhitespaceChatacter]]
Source code in src/toolbox_pyspark/utils/whitespaces.py
32
33
34
35
36
def to_list(
    self,
    attr: Optional[Literal["name", "unicode", "ascii", "chr"]] = None,
) -> List[Union[str, int, WhitespaceChatacter]]:
    return [char if attr is None else char[attr] for char in self]