Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/tomlkit/toml_char.py: 92%
24 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 07:01 +0000
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 07:01 +0000
1import string
4class TOMLChar(str):
5 def __init__(self, c):
6 super().__init__()
8 if len(self) > 1:
9 raise ValueError("A TOML character must be of length 1")
11 BARE = string.ascii_letters + string.digits + "-_"
12 KV = "= \t"
13 NUMBER = string.digits + "+-_.e"
14 SPACES = " \t"
15 NL = "\n\r"
16 WS = SPACES + NL
18 def is_bare_key_char(self) -> bool:
19 """
20 Whether the character is a valid bare key name or not.
21 """
22 return self in self.BARE
24 def is_kv_sep(self) -> bool:
25 """
26 Whether the character is a valid key/value separator or not.
27 """
28 return self in self.KV
30 def is_int_float_char(self) -> bool:
31 """
32 Whether the character if a valid integer or float value character or not.
33 """
34 return self in self.NUMBER
36 def is_ws(self) -> bool:
37 """
38 Whether the character is a whitespace character or not.
39 """
40 return self in self.WS
42 def is_nl(self) -> bool:
43 """
44 Whether the character is a new line character or not.
45 """
46 return self in self.NL
48 def is_spaces(self) -> bool:
49 """
50 Whether the character is a space or not
51 """
52 return self in self.SPACES