omlish 0.0.0.dev192__py3-none-any.whl → 0.0.0.dev194__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- omlish/.manifests.json +17 -3
- omlish/__about__.py +2 -2
- omlish/codecs/base.py +2 -0
- omlish/configs/__init__.py +0 -5
- omlish/configs/formats.py +247 -0
- omlish/configs/nginx.py +72 -0
- omlish/configs/processing/__init__.py +0 -0
- omlish/configs/{flattening.py → processing/flattening.py} +31 -33
- omlish/configs/processing/inheritance.py +58 -0
- omlish/configs/processing/matching.py +53 -0
- omlish/configs/processing/names.py +50 -0
- omlish/configs/processing/rewriting.py +141 -0
- omlish/configs/processing/strings.py +45 -0
- omlish/configs/types.py +9 -0
- omlish/formats/__init__.py +4 -0
- omlish/formats/ini/__init__.py +0 -0
- omlish/formats/ini/codec.py +26 -0
- omlish/formats/ini/sections.py +45 -0
- omlish/formats/toml/__init__.py +0 -0
- omlish/formats/{toml.py → toml/codec.py} +2 -2
- omlish/formats/toml/parser.py +827 -0
- omlish/formats/toml/writer.py +124 -0
- omlish/lang/__init__.py +4 -1
- omlish/lang/iterables.py +0 -7
- omlish/lite/configs.py +38 -0
- omlish/lite/types.py +9 -0
- omlish/text/glyphsplit.py +25 -10
- {omlish-0.0.0.dev192.dist-info → omlish-0.0.0.dev194.dist-info}/METADATA +1 -1
- {omlish-0.0.0.dev192.dist-info → omlish-0.0.0.dev194.dist-info}/RECORD +33 -17
- omlish/configs/strings.py +0 -96
- {omlish-0.0.0.dev192.dist-info → omlish-0.0.0.dev194.dist-info}/LICENSE +0 -0
- {omlish-0.0.0.dev192.dist-info → omlish-0.0.0.dev194.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev192.dist-info → omlish-0.0.0.dev194.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev192.dist-info → omlish-0.0.0.dev194.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,124 @@
|
|
1
|
+
# @omlish-lite
|
2
|
+
import dataclasses as dc
|
3
|
+
import io
|
4
|
+
import string
|
5
|
+
import typing as ta
|
6
|
+
|
7
|
+
|
8
|
+
class TomlWriter:
|
9
|
+
@dc.dataclass(frozen=True)
|
10
|
+
class Literal:
|
11
|
+
s: str
|
12
|
+
|
13
|
+
def __init__(self, out: ta.TextIO) -> None:
|
14
|
+
super().__init__()
|
15
|
+
self._out = out
|
16
|
+
|
17
|
+
self._indent = 0
|
18
|
+
self._wrote_indent = False
|
19
|
+
|
20
|
+
#
|
21
|
+
|
22
|
+
def _w(self, s: str) -> None:
|
23
|
+
if not self._wrote_indent:
|
24
|
+
self._out.write(' ' * self._indent)
|
25
|
+
self._wrote_indent = True
|
26
|
+
self._out.write(s)
|
27
|
+
|
28
|
+
def _nl(self) -> None:
|
29
|
+
self._out.write('\n')
|
30
|
+
self._wrote_indent = False
|
31
|
+
|
32
|
+
def _needs_quote(self, s: str) -> bool:
|
33
|
+
return (
|
34
|
+
not s or
|
35
|
+
any(c in s for c in '\'"\n') or
|
36
|
+
s[0] not in string.ascii_letters
|
37
|
+
)
|
38
|
+
|
39
|
+
def _maybe_quote(self, s: str) -> str:
|
40
|
+
if self._needs_quote(s):
|
41
|
+
return repr(s)
|
42
|
+
else:
|
43
|
+
return s
|
44
|
+
|
45
|
+
#
|
46
|
+
|
47
|
+
def write_root(self, obj: ta.Mapping) -> None:
|
48
|
+
for i, (k, v) in enumerate(obj.items()):
|
49
|
+
if i:
|
50
|
+
self._nl()
|
51
|
+
self._w('[')
|
52
|
+
self._w(self._maybe_quote(k))
|
53
|
+
self._w(']')
|
54
|
+
self._nl()
|
55
|
+
self.write_table_contents(v)
|
56
|
+
|
57
|
+
def write_table_contents(self, obj: ta.Mapping) -> None:
|
58
|
+
for k, v in obj.items():
|
59
|
+
self.write_key(k)
|
60
|
+
self._w(' = ')
|
61
|
+
self.write_value(v)
|
62
|
+
self._nl()
|
63
|
+
|
64
|
+
def write_array(self, obj: ta.Sequence) -> None:
|
65
|
+
self._w('[')
|
66
|
+
self._nl()
|
67
|
+
self._indent += 1
|
68
|
+
for e in obj:
|
69
|
+
self.write_value(e)
|
70
|
+
self._w(',')
|
71
|
+
self._nl()
|
72
|
+
self._indent -= 1
|
73
|
+
self._w(']')
|
74
|
+
|
75
|
+
def write_inline_table(self, obj: ta.Mapping) -> None:
|
76
|
+
self._w('{')
|
77
|
+
for i, (k, v) in enumerate(obj.items()):
|
78
|
+
if i:
|
79
|
+
self._w(', ')
|
80
|
+
self.write_key(k)
|
81
|
+
self._w(' = ')
|
82
|
+
self.write_value(v)
|
83
|
+
self._w('}')
|
84
|
+
|
85
|
+
def write_inline_array(self, obj: ta.Sequence) -> None:
|
86
|
+
self._w('[')
|
87
|
+
for i, e in enumerate(obj):
|
88
|
+
if i:
|
89
|
+
self._w(', ')
|
90
|
+
self.write_value(e)
|
91
|
+
self._w(']')
|
92
|
+
|
93
|
+
def write_key(self, obj: ta.Any) -> None:
|
94
|
+
if isinstance(obj, TomlWriter.Literal):
|
95
|
+
self._w(obj.s)
|
96
|
+
elif isinstance(obj, str):
|
97
|
+
self._w(self._maybe_quote(obj.replace('_', '-')))
|
98
|
+
elif isinstance(obj, int):
|
99
|
+
self._w(repr(str(obj)))
|
100
|
+
else:
|
101
|
+
raise TypeError(obj)
|
102
|
+
|
103
|
+
def write_value(self, obj: ta.Any) -> None:
|
104
|
+
if isinstance(obj, bool):
|
105
|
+
self._w(str(obj).lower())
|
106
|
+
elif isinstance(obj, (str, int, float)):
|
107
|
+
self._w(repr(obj))
|
108
|
+
elif isinstance(obj, ta.Mapping):
|
109
|
+
self.write_inline_table(obj)
|
110
|
+
elif isinstance(obj, ta.Sequence):
|
111
|
+
if not obj:
|
112
|
+
self.write_inline_array(obj)
|
113
|
+
else:
|
114
|
+
self.write_array(obj)
|
115
|
+
else:
|
116
|
+
raise TypeError(obj)
|
117
|
+
|
118
|
+
#
|
119
|
+
|
120
|
+
@classmethod
|
121
|
+
def write_str(cls, obj: ta.Any) -> str:
|
122
|
+
out = io.StringIO()
|
123
|
+
cls(out).write_value(obj)
|
124
|
+
return out.getvalue()
|
omlish/lang/__init__.py
CHANGED
@@ -147,7 +147,6 @@ from .imports import ( # noqa
|
|
147
147
|
)
|
148
148
|
|
149
149
|
from .iterables import ( # noqa
|
150
|
-
BUILTIN_SCALAR_ITERABLE_TYPES,
|
151
150
|
asrange,
|
152
151
|
exhaust,
|
153
152
|
flatmap,
|
@@ -238,6 +237,10 @@ from .typing import ( # noqa
|
|
238
237
|
|
239
238
|
##
|
240
239
|
|
240
|
+
from ..lite.types import ( # noqa
|
241
|
+
BUILTIN_SCALAR_ITERABLE_TYPES,
|
242
|
+
)
|
243
|
+
|
241
244
|
from ..lite.typing import ( # noqa
|
242
245
|
AnyFunc,
|
243
246
|
Func0,
|
omlish/lang/iterables.py
CHANGED
omlish/lite/configs.py
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# ruff: noqa: UP006 UP007
|
2
|
+
import typing as ta
|
3
|
+
|
4
|
+
from ..configs.formats import DEFAULT_CONFIG_FILE_LOADER
|
5
|
+
from ..configs.types import ConfigMap
|
6
|
+
from .marshal import OBJ_MARSHALER_MANAGER
|
7
|
+
from .marshal import ObjMarshalerManager
|
8
|
+
|
9
|
+
|
10
|
+
T = ta.TypeVar('T')
|
11
|
+
|
12
|
+
|
13
|
+
##
|
14
|
+
|
15
|
+
|
16
|
+
def load_config_file_obj(
|
17
|
+
f: str,
|
18
|
+
cls: ta.Type[T],
|
19
|
+
*,
|
20
|
+
prepare: ta.Union[
|
21
|
+
ta.Callable[[ConfigMap], ConfigMap],
|
22
|
+
ta.Iterable[ta.Callable[[ConfigMap], ConfigMap]],
|
23
|
+
] = (),
|
24
|
+
msh: ObjMarshalerManager = OBJ_MARSHALER_MANAGER,
|
25
|
+
) -> T:
|
26
|
+
config_data = DEFAULT_CONFIG_FILE_LOADER.load_file(f)
|
27
|
+
|
28
|
+
config_dct = config_data.as_map()
|
29
|
+
|
30
|
+
if prepare is not None:
|
31
|
+
if isinstance(prepare, ta.Iterable):
|
32
|
+
pfs = list(prepare)
|
33
|
+
else:
|
34
|
+
pfs = [prepare]
|
35
|
+
for pf in pfs:
|
36
|
+
config_dct = pf(config_dct)
|
37
|
+
|
38
|
+
return msh.unmarshal_obj(config_dct, cls)
|
omlish/lite/types.py
ADDED
omlish/text/glyphsplit.py
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# ruff: noqa: UP006 UP007
|
2
|
+
# @omlish-lite
|
1
3
|
"""
|
2
4
|
Note: string.Formatter (and string.Template) shouldn't be ignored - if they can be used they probably should be.
|
3
5
|
- https://docs.python.org/3/library/string.html#custom-string-formatting
|
@@ -5,22 +7,22 @@ Note: string.Formatter (and string.Template) shouldn't be ignored - if they can
|
|
5
7
|
"""
|
6
8
|
import dataclasses as dc
|
7
9
|
import re
|
10
|
+
import typing as ta
|
8
11
|
|
9
|
-
from .. import check
|
12
|
+
from ..lite.check import check
|
10
13
|
|
11
14
|
|
12
15
|
@dc.dataclass(frozen=True)
|
13
|
-
class
|
16
|
+
class GlyphSplitMatch:
|
14
17
|
l: str
|
15
18
|
s: str
|
16
19
|
r: str
|
17
20
|
|
18
21
|
|
19
22
|
class GlyphSplitter:
|
20
|
-
|
21
23
|
def __init__(
|
22
24
|
self,
|
23
|
-
glyphs:
|
25
|
+
glyphs: ta.Tuple[str, str],
|
24
26
|
*,
|
25
27
|
escape_returned_doubles: bool = False,
|
26
28
|
compact: bool = False,
|
@@ -49,7 +51,7 @@ class GlyphSplitter:
|
|
49
51
|
|
50
52
|
self._single_glyph_pat = re.compile(r'(%s[^%s]*?%s)' % (self._l_escaped_glyph, self._r_escaped_glyph, self._r_escaped_glyph)) # noqa
|
51
53
|
|
52
|
-
def split(self, s: str) ->
|
54
|
+
def split(self, s: str) -> ta.List[ta.Union[GlyphSplitMatch, str]]:
|
53
55
|
ps = self._l_glyph_pat.split(s)
|
54
56
|
ps = [p[::-1] for p in ps for p in reversed(self._r_glyph_pat.split(p[::-1]))]
|
55
57
|
|
@@ -77,7 +79,7 @@ class GlyphSplitter:
|
|
77
79
|
for m in ms:
|
78
80
|
if m.start() != l:
|
79
81
|
append_ret(p[l:m.start()])
|
80
|
-
append_ret(
|
82
|
+
append_ret(GlyphSplitMatch(self._l_glyph, p[m.start() + 1:m.end() - 1], self._r_glyph))
|
81
83
|
l = m.end()
|
82
84
|
|
83
85
|
if l < len(p):
|
@@ -91,7 +93,20 @@ _BRACE_GLYPH_SPLITTER = GlyphSplitter(('{', '}'), escape_returned_doubles=True,
|
|
91
93
|
_BRACKET_GLYPH_SPLITTER = GlyphSplitter(('[', ']'), escape_returned_doubles=True, compact=True)
|
92
94
|
_ANGLE_BRACKET_GLYPH_SPLITTER = GlyphSplitter(('<', '>'), escape_returned_doubles=True, compact=True)
|
93
95
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
96
|
+
glyph_split_parens = _PAREN_GLYPH_SPLITTER.split
|
97
|
+
glyph_split_braces = _BRACE_GLYPH_SPLITTER.split
|
98
|
+
glyph_split_brackets = _BRACKET_GLYPH_SPLITTER.split
|
99
|
+
glyph_split_angle_brackets = _ANGLE_BRACKET_GLYPH_SPLITTER.split
|
100
|
+
|
101
|
+
|
102
|
+
def glyph_split_interpolate(
|
103
|
+
split_fn: ta.Callable[[str], ta.Sequence[ta.Union[GlyphSplitMatch, str]]],
|
104
|
+
dct: ta.Mapping[str, str],
|
105
|
+
s: str,
|
106
|
+
) -> str:
|
107
|
+
if not s:
|
108
|
+
return s
|
109
|
+
sps = split_fn(s)
|
110
|
+
if len(sps) == 1 and isinstance(sps[0], str):
|
111
|
+
return sps[0]
|
112
|
+
return ''.join(dct[p.s] if isinstance(p, GlyphSplitMatch) else p for p in sps)
|
@@ -1,5 +1,5 @@
|
|
1
|
-
omlish/.manifests.json,sha256=
|
2
|
-
omlish/__about__.py,sha256=
|
1
|
+
omlish/.manifests.json,sha256=dyIpveH7Z8OnQp2pTn6NVv7LCDXVrozJWAzbk8PBavg,7950
|
2
|
+
omlish/__about__.py,sha256=EGlq5fZGiyJg2x9ba9tOUhbLf6OjV9lr0mNkhwX1DnU,3409
|
3
3
|
omlish/__init__.py,sha256=SsyiITTuK0v74XpKV8dqNaCmjOlan1JZKrHQv5rWKPA,253
|
4
4
|
omlish/c3.py,sha256=ubu7lHwss5V4UznbejAI0qXhXahrU01MysuHOZI9C4U,8116
|
5
5
|
omlish/cached.py,sha256=UI-XTFBwA6YXWJJJeBn-WkwBkfzDjLBBaZf4nIJA9y0,510
|
@@ -117,7 +117,7 @@ omlish/bootstrap/main.py,sha256=yZhOHDDlj4xB5a89dRdT8z58FsqqnpoBg1-tvY2CJe4,5903
|
|
117
117
|
omlish/bootstrap/marshal.py,sha256=ZxdAeMNd2qXRZ1HUK89HmEhz8tqlS9OduW34QBscKw0,516
|
118
118
|
omlish/bootstrap/sys.py,sha256=aqMzxZa_lPj78cgz4guYZAkjT6En32e2LptfEo20NIM,8769
|
119
119
|
omlish/codecs/__init__.py,sha256=-FDwRJFGagg-fZyQ8wup4GPuR6gHpmaChzthlykn-kY,876
|
120
|
-
omlish/codecs/base.py,sha256=
|
120
|
+
omlish/codecs/base.py,sha256=JXTFSLnX5qPbi4NSbbI5uB3tYhs2SN0g_eWN2UskPYE,2242
|
121
121
|
omlish/codecs/bytes.py,sha256=jlZ87OmZ52HhQDNyL87R3OIviK2qV5iU2jZYOTOLWjk,2157
|
122
122
|
omlish/codecs/chain.py,sha256=DrBi5vbaFfObfoppo6alwOmyW2XbrH2051cjExwr2Gs,527
|
123
123
|
omlish/codecs/funcs.py,sha256=p4imNt7TobyZVXWC-WhntHVu9KfJrO4QwdtPRh-cVOk,850
|
@@ -149,10 +149,18 @@ omlish/concurrent/__init__.py,sha256=9p-s8MvBEYDqHIoYU3OYoe-Nni22QdkW7nhZGEukJTM
|
|
149
149
|
omlish/concurrent/executors.py,sha256=FYKCDYYuj-OgMa8quLsA47SfFNX3KDJvRENVk8NDsrA,1292
|
150
150
|
omlish/concurrent/futures.py,sha256=J2s9wYURUskqRJiBbAR0PNEAp1pXbIMYldOVBTQduQY,4239
|
151
151
|
omlish/concurrent/threadlets.py,sha256=JfirbTDJgy9Ouokz_VmHeAAPS7cih8qMUJrN-owwXD4,2423
|
152
|
-
omlish/configs/__init__.py,sha256=
|
152
|
+
omlish/configs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
153
153
|
omlish/configs/classes.py,sha256=GLbB8xKjHjjoUQRCUQm3nEjM8z1qNTx9gPV7ODSt5dg,1317
|
154
|
-
omlish/configs/
|
155
|
-
omlish/configs/
|
154
|
+
omlish/configs/formats.py,sha256=RJw4Rzp7vlTd5YyAvpAoruQnk45v8dGPtPWwqH7aYyE,5301
|
155
|
+
omlish/configs/nginx.py,sha256=XuX9yyb0_MwkJ8esKiMS9gFkqHUPza_uCprhnWykNy8,2051
|
156
|
+
omlish/configs/types.py,sha256=t5_32MVRSKxbxor1hl1wRGKYm75F6Atisd_RYsN5ELU,103
|
157
|
+
omlish/configs/processing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
158
|
+
omlish/configs/processing/flattening.py,sha256=1duZH5zbrGuoYqaJco5LN5qx6e76QP5pHbIyItkQsFY,5021
|
159
|
+
omlish/configs/processing/inheritance.py,sha256=lFD8eWRE0cG0Z3-eCu7pMsP2skWhUNaoAtWi9fNfn8k,1218
|
160
|
+
omlish/configs/processing/matching.py,sha256=JMS9r58pMCBbpewOhPY5oPtBu3uD6z6YBfZq4jnLwBE,1236
|
161
|
+
omlish/configs/processing/names.py,sha256=weHmaTclzgM9lUn3aBtw-kwZ3mc2N-CZlFg3Kd_UsKo,1093
|
162
|
+
omlish/configs/processing/rewriting.py,sha256=v7PfHtuTn5v_5Y6Au7oMN2Z0nxAMy1iYyO5CXnTvZhs,4226
|
163
|
+
omlish/configs/processing/strings.py,sha256=qFS2oh6z02IaM_q4lTKLdufzkJqAJ6J-Qjrz5S-QJoM,826
|
156
164
|
omlish/dataclasses/__init__.py,sha256=AHo-tN5V_b_VYFUF7VFRmuHrjZBXS1WytRAj061MUTA,1423
|
157
165
|
omlish/dataclasses/utils.py,sha256=lcikCPiiX5Giu0Kb1hP18loZjmm_Z9D-XtJ-ZlHq9iM,3793
|
158
166
|
omlish/dataclasses/impl/LICENSE,sha256=Oy-B_iHRgcSZxZolbI4ZaEVdZonSaaqFNzv7avQdo78,13936
|
@@ -209,7 +217,7 @@ omlish/docker/detect.py,sha256=Qrdbosm2wJkxKDuy8gaGmbQoxk4Wnp1HJjAEz58NA8Y,614
|
|
209
217
|
omlish/docker/hub.py,sha256=7LIuJGdA-N1Y1dmo50ynKM1KUTcnQM_5XbtPbdT_QLU,3940
|
210
218
|
omlish/docker/manifests.py,sha256=LR4FpOGNUT3bZQ-gTjB6r_-1C3YiG30QvevZjrsVUQM,7068
|
211
219
|
omlish/docker/timebomb.py,sha256=A_pgIDaXKsQwPiikrCTgIJl91gwYqkPGFY6j-Naq07Q,342
|
212
|
-
omlish/formats/__init__.py,sha256=
|
220
|
+
omlish/formats/__init__.py,sha256=T0AG1gFnqQ5JiHN0UPQjQ-7g5tnxMIG-mgOvMYExYAM,21
|
213
221
|
omlish/formats/cbor.py,sha256=o_Hbe4kthO9CeXK-FySrw0dHVlrdyTo2Y8PpGRDfZ3c,514
|
214
222
|
omlish/formats/cloudpickle.py,sha256=16si4yUp_pAdDWGECAWf6HLA2PwSANGGgDoMLGZUem8,579
|
215
223
|
omlish/formats/codecs.py,sha256=6AbKIz_gl_om36-7qsutybYzK8cJP3LzwC9YJlwCPOA,1590
|
@@ -218,9 +226,11 @@ omlish/formats/json5.py,sha256=odpZIShlUpv19aACWe58SoMPcv0AHKIa6zSMjlKgaMI,515
|
|
218
226
|
omlish/formats/pickle.py,sha256=jdp4E9WH9qVPBE3sSqbqDtUo18RbTSIiSpSzJ-IEVZw,529
|
219
227
|
omlish/formats/props.py,sha256=cek3JLFLIrpE76gvs8rs_B8yF4SpY8ooDH8apWsquwE,18953
|
220
228
|
omlish/formats/repr.py,sha256=kYrNs4o-ji8nOdp6u_L3aMgBMWN1ZAZJSAWgQQfStSQ,414
|
221
|
-
omlish/formats/toml.py,sha256=AhpVNAy87eBohBCsvIvwH2ucASWxnWXMEsMH8zB7rpI,340
|
222
229
|
omlish/formats/xml.py,sha256=ggiOwSERt4d9XmZwLZiDIh5qnFJS4jdmow9m9_9USps,1491
|
223
230
|
omlish/formats/yaml.py,sha256=ffOwGnLA6chdiFyaS7X0TBMGmHG9AoGudzKVWfQ1UOs,7389
|
231
|
+
omlish/formats/ini/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
232
|
+
omlish/formats/ini/codec.py,sha256=omuFg0kiDksv8rRlWd_v32ebzEcKlgmiPgGID3bRi2M,631
|
233
|
+
omlish/formats/ini/sections.py,sha256=7wYyZdVTQbMPFpjQEACKJfAEPzUBrogINsrvFgxJoZ0,1015
|
224
234
|
omlish/formats/json/__init__.py,sha256=y7T-Jm-7FuQFzb-6uedky0ZhBaKtCKzcu291juXfiWI,669
|
225
235
|
omlish/formats/json/codecs.py,sha256=E5KErfqsgGZq763ixXLT3qysbk5MIsypT92xG5aSaIs,796
|
226
236
|
omlish/formats/json/consts.py,sha256=A0cTAGGLyjo-gcYIQrL4JIaardI0yPMhQoNmh42BaRg,387
|
@@ -243,6 +253,10 @@ omlish/formats/json/stream/errors.py,sha256=c8M8UAYmIZ-vWZLeKD2jMj4EDCJbr9QR8Jq_
|
|
243
253
|
omlish/formats/json/stream/lex.py,sha256=bfy0fb3_Z6G18UGueX2DR6oPSVUsMoFhlbsvXC3ztzI,6793
|
244
254
|
omlish/formats/json/stream/parse.py,sha256=JuYmXwtTHmQJTFKoJNoEHUpCPxXdl_gvKPykVXgED34,6208
|
245
255
|
omlish/formats/json/stream/render.py,sha256=NtmDsN92xZi5dkgSSuMeMXMAiJblmjz1arB4Ft7vBhc,3715
|
256
|
+
omlish/formats/toml/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
257
|
+
omlish/formats/toml/codec.py,sha256=5HFGWEPd9IFxPlRMRheX8FEDlRIzLe1moHEOj2_PFKU,342
|
258
|
+
omlish/formats/toml/parser.py,sha256=3QN3rqdJ_zlHfFtsDn-A9pl-BTwdVMUUpUV5-lGWCKc,29342
|
259
|
+
omlish/formats/toml/writer.py,sha256=HIp6XvriXaPTLqyLe-fkIiEf1Pyhsp0TcOg5rFBpO3g,3226
|
246
260
|
omlish/funcs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
247
261
|
omlish/funcs/genmachine.py,sha256=EY2k-IFNKMEmHo9CmGRptFvhEMZVOWzZhn0wdQGeaFM,2476
|
248
262
|
omlish/funcs/match.py,sha256=gMLZn1enNiFvQaWrQubY300M1BrmdKWzeePihBS7Ywc,6153
|
@@ -341,7 +355,7 @@ omlish/iterators/iterators.py,sha256=ghI4dO6WPyyFOLTIIMaHQ_IOy2xXaFpGPqveZ5YGIBU
|
|
341
355
|
omlish/iterators/recipes.py,sha256=53mkexitMhkwXQZbL6DrhpT0WePQ_56uXd5Jaw3DfzI,467
|
342
356
|
omlish/iterators/tools.py,sha256=SvXyyQJh7aceLYhRl6pQB-rfSaXw5IMIWukeEeOZt-0,2492
|
343
357
|
omlish/iterators/unique.py,sha256=0jAX3kwzVfRNhe0Tmh7kVP_Q2WBIn8POo_O-rgFV0rQ,1390
|
344
|
-
omlish/lang/__init__.py,sha256=
|
358
|
+
omlish/lang/__init__.py,sha256=GqZ3exAAK7iphRf8e4d3CvAz7EptvmEOmCkmN06uYvQ,3986
|
345
359
|
omlish/lang/cached.py,sha256=92TvRZQ6sWlm7dNn4hgl7aWKbX0J1XUEo3DRjBpgVQk,7834
|
346
360
|
omlish/lang/clsdct.py,sha256=AjtIWLlx2E6D5rC97zQ3Lwq2SOMkbg08pdO_AxpzEHI,1744
|
347
361
|
omlish/lang/cmp.py,sha256=5vbzWWbqdzDmNKAGL19z6ZfUKe5Ci49e-Oegf9f4BsE,1346
|
@@ -352,7 +366,7 @@ omlish/lang/exceptions.py,sha256=qJBo3NU1mOWWm-NhQUHCY5feYXR3arZVyEHinLsmRH4,47
|
|
352
366
|
omlish/lang/functions.py,sha256=t9nsnWwhsibG0w908VMx-_pRM5tZfruE3faPxrCWTbI,4160
|
353
367
|
omlish/lang/generators.py,sha256=5LX17j-Ej3QXhwBgZvRTm_dq3n9veC4IOUcVmvSu2vU,5243
|
354
368
|
omlish/lang/imports.py,sha256=TXLbj2F53LsmozlM05bQhvow9kEgWJOi9qYKsnm2D18,9258
|
355
|
-
omlish/lang/iterables.py,sha256=
|
369
|
+
omlish/lang/iterables.py,sha256=HOjcxOwyI5bBApDLsxRAGGhTTmw7fdZl2kEckxRVl-0,1994
|
356
370
|
omlish/lang/maybes.py,sha256=1RN7chX_x2XvgUwryZRz0W7hAX-be3eEFcFub5vvf6M,3417
|
357
371
|
omlish/lang/objects.py,sha256=LOC3JvX1g5hPxJ7Sv2TK9kNkAo9c8J-Jw2NmClR_rkA,4576
|
358
372
|
omlish/lang/resolving.py,sha256=OuN2mDTPNyBUbcrswtvFKtj4xgH4H4WglgqSKv3MTy0,1606
|
@@ -377,6 +391,7 @@ omlish/lifecycles/transitions.py,sha256=qQtFby-h4VzbvgaUqT2NnbNumlcOx9FVVADP9t83
|
|
377
391
|
omlish/lite/__init__.py,sha256=ISLhM4q0LR1XXTCaHdZOZxBRyIsoZqYm4u0bf1BPcVk,148
|
378
392
|
omlish/lite/cached.py,sha256=O7ozcoDNFm1Hg2wtpHEqYSp_i_nCLNOP6Ueq_Uk-7mU,1300
|
379
393
|
omlish/lite/check.py,sha256=0PD-GKtaDqDX6jU5KbzbMvH-vl6jH82xgYfplmfTQkg,12941
|
394
|
+
omlish/lite/configs.py,sha256=Ev_19sbII67pTWzInYjYqa9VyTiZBvyjhZqyG8TtufE,908
|
380
395
|
omlish/lite/contextmanagers.py,sha256=m9JO--p7L7mSl4cycXysH-1AO27weDKjP3DZG61cwwM,1683
|
381
396
|
omlish/lite/dataclasses.py,sha256=M6UD4VwGo0Ky7RNzKWbO0IOy7iBZVCIbTiC6EYbFnX8,1035
|
382
397
|
omlish/lite/inject.py,sha256=qBUftFeXMiRgANYbNS2e7TePMYyFAcuLgsJiLyMTW5o,28769
|
@@ -390,6 +405,7 @@ omlish/lite/resources.py,sha256=YNSmX1Ohck1aoWRs55a-o5ChVbFJIQhtbqE-XwF55Oc,326
|
|
390
405
|
omlish/lite/runtime.py,sha256=XQo408zxTdJdppUZqOWHyeUR50VlCpNIExNGHz4U6O4,459
|
391
406
|
omlish/lite/secrets.py,sha256=3Mz3V2jf__XU9qNHcH56sBSw95L3U2UPL24bjvobG0c,816
|
392
407
|
omlish/lite/strings.py,sha256=nGWaOi9LzTjkc5kPN2IqsVN8PUw8m_2yllTGRUQU5PI,1983
|
408
|
+
omlish/lite/types.py,sha256=fP5EMyBdEp2LmDxcHjUDtwAMdR06ISr9lKOL7smWfHM,140
|
393
409
|
omlish/lite/typing.py,sha256=U3-JaEnkDSYxK4tsu_MzUn3RP6qALBe5FXQXpD-licE,1090
|
394
410
|
omlish/logs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
395
411
|
omlish/logs/abc.py,sha256=ho4ABKYMKX-V7g4sp1BByuOLzslYzLlQ0MESmjEpT-o,8005
|
@@ -574,14 +590,14 @@ omlish/testing/pytest/plugins/utils.py,sha256=L5C622UXcA_AUKDcvyh5IMiRfqSGGz0Mcd
|
|
574
590
|
omlish/text/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
575
591
|
omlish/text/asdl.py,sha256=AS3irh-sag5pqyH3beJif78PjCbOaFso1NeKq-HXuTs,16867
|
576
592
|
omlish/text/delimit.py,sha256=ubPXcXQmtbOVrUsNh5gH1mDq5H-n1y2R4cPL5_DQf68,4928
|
577
|
-
omlish/text/glyphsplit.py,sha256=
|
593
|
+
omlish/text/glyphsplit.py,sha256=kqqjglRdxGo0czYZxOz9Vi8aBmVsCOq8h6lPwRA5xe0,3803
|
578
594
|
omlish/text/indent.py,sha256=XixaVnk9bvtBlH0n_cwN6yS5IyfrTWpe_alfu3_saLY,1341
|
579
595
|
omlish/text/minja.py,sha256=KAmZ2POcLcxwF4DPKxdWa16uWxXmVz1UnJXLSwt4oZo,5761
|
580
596
|
omlish/text/parts.py,sha256=7vPF1aTZdvLVYJ4EwBZVzRSy8XB3YqPd7JwEnNGGAOo,6495
|
581
597
|
omlish/text/random.py,sha256=jNWpqiaKjKyTdMXC-pWAsSC10AAP-cmRRPVhm59ZWLk,194
|
582
|
-
omlish-0.0.0.
|
583
|
-
omlish-0.0.0.
|
584
|
-
omlish-0.0.0.
|
585
|
-
omlish-0.0.0.
|
586
|
-
omlish-0.0.0.
|
587
|
-
omlish-0.0.0.
|
598
|
+
omlish-0.0.0.dev194.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
599
|
+
omlish-0.0.0.dev194.dist-info/METADATA,sha256=nhNsVPo6hNygJ8DxnRbJE-iqP-emALofRYUylUQkyJc,4264
|
600
|
+
omlish-0.0.0.dev194.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
601
|
+
omlish-0.0.0.dev194.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
|
602
|
+
omlish-0.0.0.dev194.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
|
603
|
+
omlish-0.0.0.dev194.dist-info/RECORD,,
|
omlish/configs/strings.py
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
TODO:
|
3
|
-
- reflecty generalized rewriter, obviously..
|
4
|
-
- env vars
|
5
|
-
- coalescing - {$FOO|$BAR|baz}
|
6
|
-
"""
|
7
|
-
import collections.abc
|
8
|
-
import typing as ta
|
9
|
-
|
10
|
-
from .. import dataclasses as dc
|
11
|
-
from .. import lang
|
12
|
-
from ..text import glyphsplit
|
13
|
-
|
14
|
-
|
15
|
-
T = ta.TypeVar('T')
|
16
|
-
|
17
|
-
|
18
|
-
class InterpolateStringsMetadata(lang.Marker):
|
19
|
-
pass
|
20
|
-
|
21
|
-
|
22
|
-
@dc.field_modifier
|
23
|
-
def secret_or_key_field(f: dc.Field) -> dc.Field:
|
24
|
-
return dc.update_field_metadata(f, {
|
25
|
-
InterpolateStringsMetadata: True,
|
26
|
-
})
|
27
|
-
|
28
|
-
|
29
|
-
@dc.field_modifier
|
30
|
-
def interpolate_field(f: dc.Field) -> dc.Field:
|
31
|
-
return dc.update_field_metadata(f, {InterpolateStringsMetadata: True})
|
32
|
-
|
33
|
-
|
34
|
-
class StringRewriter:
|
35
|
-
def __init__(self, fn: ta.Callable[[str], str]) -> None:
|
36
|
-
super().__init__()
|
37
|
-
self._fn = fn
|
38
|
-
|
39
|
-
def __call__(self, v: T, *, _soft: bool = False) -> T:
|
40
|
-
if v is None:
|
41
|
-
return None # type: ignore
|
42
|
-
|
43
|
-
if dc.is_dataclass(v):
|
44
|
-
kw = {}
|
45
|
-
for f in dc.fields(v):
|
46
|
-
fv = getattr(v, f.name)
|
47
|
-
nfv = self(fv, _soft=not f.metadata.get(InterpolateStringsMetadata))
|
48
|
-
if fv is not nfv:
|
49
|
-
kw[f.name] = nfv
|
50
|
-
if not kw:
|
51
|
-
return v # type: ignore
|
52
|
-
return dc.replace(v, **kw)
|
53
|
-
|
54
|
-
if isinstance(v, str):
|
55
|
-
if not _soft:
|
56
|
-
v = self._fn(v) # type: ignore
|
57
|
-
return v # type: ignore
|
58
|
-
|
59
|
-
if isinstance(v, lang.BUILTIN_SCALAR_ITERABLE_TYPES):
|
60
|
-
return v # type: ignore
|
61
|
-
|
62
|
-
if isinstance(v, collections.abc.Mapping):
|
63
|
-
nm = []
|
64
|
-
b = False
|
65
|
-
for mk, mv in v.items():
|
66
|
-
nk, nv = self(mk, _soft=_soft), self(mv, _soft=_soft)
|
67
|
-
nm.append((nk, nv))
|
68
|
-
b |= nk is not mk or nv is not mv
|
69
|
-
if not b:
|
70
|
-
return v # type: ignore
|
71
|
-
return v.__class__(nm) # type: ignore
|
72
|
-
|
73
|
-
if isinstance(v, (collections.abc.Sequence, collections.abc.Set)):
|
74
|
-
nl = []
|
75
|
-
b = False
|
76
|
-
for le in v:
|
77
|
-
ne = self(le, _soft=_soft)
|
78
|
-
nl.append(ne)
|
79
|
-
b |= ne is not le
|
80
|
-
if not b:
|
81
|
-
return v # type: ignore
|
82
|
-
return v.__class__(nl) # type: ignore
|
83
|
-
|
84
|
-
return v
|
85
|
-
|
86
|
-
|
87
|
-
def interpolate_strings(v: T, rpl: ta.Mapping[str, str]) -> T:
|
88
|
-
def fn(v):
|
89
|
-
if not v:
|
90
|
-
return v
|
91
|
-
sps = glyphsplit.split_braces(v)
|
92
|
-
if len(sps) == 1 and isinstance(sps[0], str):
|
93
|
-
return sps[0]
|
94
|
-
return ''.join(rpl[p.s] if isinstance(p, glyphsplit.GlyphMatch) else p for p in sps)
|
95
|
-
|
96
|
-
return StringRewriter(fn)(v)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|