omlish 0.0.0.dev201__py3-none-any.whl → 0.0.0.dev203__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/__about__.py +2 -2
- omlish/formats/props.py +1 -2
- omlish/formats/xml.py +70 -16
- omlish/lang/__init__.py +2 -1
- omlish/lang/resources.py +18 -5
- omlish/sql/abc.py +13 -0
- {omlish-0.0.0.dev201.dist-info → omlish-0.0.0.dev203.dist-info}/METADATA +1 -1
- {omlish-0.0.0.dev201.dist-info → omlish-0.0.0.dev203.dist-info}/RECORD +12 -12
- {omlish-0.0.0.dev201.dist-info → omlish-0.0.0.dev203.dist-info}/LICENSE +0 -0
- {omlish-0.0.0.dev201.dist-info → omlish-0.0.0.dev203.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev201.dist-info → omlish-0.0.0.dev203.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev201.dist-info → omlish-0.0.0.dev203.dist-info}/top_level.txt +0 -0
omlish/__about__.py
CHANGED
omlish/formats/props.py
CHANGED
@@ -306,8 +306,7 @@ class Properties(collections.abc.MutableMapping):
|
|
306
306
|
if self._metadoc and self._prev_key:
|
307
307
|
prev_metadata = self._metadata.setdefault(self._prev_key, {})
|
308
308
|
prev_metadata.setdefault('_doc', '')
|
309
|
-
|
310
|
-
docstr = docstr[1:]
|
309
|
+
docstr = docstr.removeprefix(' ')
|
311
310
|
prev_metadata['_doc'] += docstr + '\n'
|
312
311
|
return
|
313
312
|
|
omlish/formats/xml.py
CHANGED
@@ -18,6 +18,49 @@ else:
|
|
18
18
|
##
|
19
19
|
|
20
20
|
|
21
|
+
def strip_ns(tag: str) -> str:
|
22
|
+
# It really do just be like this:
|
23
|
+
# https://github.com/python/cpython/blob/ff3bc82f7c9882c27aad597aac79355da7257186/Lib/xml/etree/ElementTree.py#L803-L804
|
24
|
+
if tag[:1] == '{':
|
25
|
+
_, tag = tag[1:].rsplit('}', 1)
|
26
|
+
return tag
|
27
|
+
|
28
|
+
|
29
|
+
##
|
30
|
+
|
31
|
+
|
32
|
+
ITER_PARSE_EVENTS = ('start', 'end', 'comment', 'pi', 'start-ns', 'end-ns')
|
33
|
+
|
34
|
+
|
35
|
+
def yield_root_children(
|
36
|
+
source: ta.Any,
|
37
|
+
*,
|
38
|
+
retain_on_root: bool = False,
|
39
|
+
**kwargs: ta.Any,
|
40
|
+
) -> ta.Iterator['ET.Element']:
|
41
|
+
it = iter(ET.iterparse(source, ('start', 'end'), **kwargs))
|
42
|
+
|
43
|
+
ev, root = next(it)
|
44
|
+
if ev != 'start':
|
45
|
+
raise RuntimeError(ev)
|
46
|
+
yield root
|
47
|
+
|
48
|
+
depth = 0
|
49
|
+
for ev, el in it:
|
50
|
+
if ev == 'start':
|
51
|
+
depth += 1
|
52
|
+
|
53
|
+
elif ev == 'end':
|
54
|
+
depth -= 1
|
55
|
+
if not depth:
|
56
|
+
if not retain_on_root:
|
57
|
+
root.remove(el)
|
58
|
+
yield el
|
59
|
+
|
60
|
+
|
61
|
+
##
|
62
|
+
|
63
|
+
|
21
64
|
@dc.dataclass(frozen=True)
|
22
65
|
class SimpleElement:
|
23
66
|
tag: str
|
@@ -36,27 +79,38 @@ class SimpleElement:
|
|
36
79
|
return dct
|
37
80
|
|
38
81
|
|
39
|
-
def build_simple_element(
|
40
|
-
|
41
|
-
|
42
|
-
|
82
|
+
def build_simple_element(
|
83
|
+
element: 'ET.Element',
|
84
|
+
*,
|
85
|
+
strip_tag_ns: bool = False,
|
86
|
+
) -> SimpleElement:
|
87
|
+
def rec(cur: 'ET.Element') -> SimpleElement:
|
88
|
+
atts = {}
|
89
|
+
for name, value in cur.attrib.items():
|
90
|
+
atts[name] = value # noqa
|
43
91
|
|
44
|
-
|
92
|
+
body: list[SimpleElement | str] = []
|
45
93
|
|
46
|
-
|
47
|
-
|
94
|
+
if cur.text and (s := cur.text.strip()):
|
95
|
+
body.append(s)
|
48
96
|
|
49
|
-
|
50
|
-
|
97
|
+
for child in cur:
|
98
|
+
body.append(rec(child))
|
51
99
|
|
52
|
-
|
53
|
-
|
100
|
+
if child.tail and (s := child.tail.strip()):
|
101
|
+
body.append(s)
|
102
|
+
|
103
|
+
tag = cur.tag
|
104
|
+
if strip_tag_ns:
|
105
|
+
tag = strip_ns(tag)
|
106
|
+
|
107
|
+
return SimpleElement(
|
108
|
+
tag,
|
109
|
+
atts,
|
110
|
+
body,
|
111
|
+
)
|
54
112
|
|
55
|
-
return
|
56
|
-
element.tag,
|
57
|
-
atts,
|
58
|
-
body,
|
59
|
-
)
|
113
|
+
return rec(element)
|
60
114
|
|
61
115
|
|
62
116
|
def parse_tree(s: str) -> 'ET.ElementTree':
|
omlish/lang/__init__.py
CHANGED
omlish/lang/resources.py
CHANGED
@@ -6,7 +6,7 @@ import typing as ta
|
|
6
6
|
|
7
7
|
|
8
8
|
@dc.dataclass(frozen=True)
|
9
|
-
class
|
9
|
+
class ReadableResource:
|
10
10
|
name: str
|
11
11
|
is_file: bool
|
12
12
|
read_bytes: ta.Callable[[], bytes]
|
@@ -15,13 +15,26 @@ class RelativeResource:
|
|
15
15
|
return self.read_bytes().decode(encoding)
|
16
16
|
|
17
17
|
|
18
|
+
def get_package_resources(anchor: str) -> ta.Mapping[str, ReadableResource]:
|
19
|
+
lst: list[ReadableResource] = []
|
20
|
+
|
21
|
+
for pf in importlib.resources.files(anchor).iterdir():
|
22
|
+
lst.append(ReadableResource(
|
23
|
+
name=pf.name,
|
24
|
+
is_file=pf.is_file(),
|
25
|
+
read_bytes=pf.read_bytes if pf.is_file() else None, # type: ignore
|
26
|
+
))
|
27
|
+
|
28
|
+
return {r.name: r for r in lst}
|
29
|
+
|
30
|
+
|
18
31
|
def get_relative_resources(
|
19
32
|
path: str = '',
|
20
33
|
*,
|
21
34
|
globals: ta.Mapping[str, ta.Any] | None = None, # noqa
|
22
35
|
package: str | None = None,
|
23
36
|
file: str | None = None,
|
24
|
-
) -> ta.Mapping[str,
|
37
|
+
) -> ta.Mapping[str, ReadableResource]:
|
25
38
|
if globals is not None:
|
26
39
|
if not package:
|
27
40
|
package = globals.get('__package__')
|
@@ -45,7 +58,7 @@ def get_relative_resources(
|
|
45
58
|
|
46
59
|
#
|
47
60
|
|
48
|
-
lst: list[
|
61
|
+
lst: list[ReadableResource] = []
|
49
62
|
|
50
63
|
if package:
|
51
64
|
pkg_parts = package.split('.')
|
@@ -53,7 +66,7 @@ def get_relative_resources(
|
|
53
66
|
pkg_parts = pkg_parts[:-num_up]
|
54
67
|
anchor = '.'.join([*pkg_parts, *path_parts])
|
55
68
|
for pf in importlib.resources.files(anchor).iterdir():
|
56
|
-
lst.append(
|
69
|
+
lst.append(ReadableResource(
|
57
70
|
name=pf.name,
|
58
71
|
is_file=pf.is_file(),
|
59
72
|
read_bytes=pf.read_bytes if pf.is_file() else None, # type: ignore
|
@@ -73,7 +86,7 @@ def get_relative_resources(
|
|
73
86
|
|
74
87
|
for ff in os.listdir(dst_dir):
|
75
88
|
ff = os.path.join(dst_dir, ff)
|
76
|
-
lst.append(
|
89
|
+
lst.append(ReadableResource(
|
77
90
|
name=os.path.basename(ff),
|
78
91
|
is_file=os.path.isfile(ff),
|
79
92
|
read_bytes=functools.partial(_read_file, ff),
|
omlish/sql/abc.py
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
"""
|
2
|
+
https://peps.python.org/pep-0249/
|
3
|
+
"""
|
1
4
|
import typing as ta
|
2
5
|
|
3
6
|
|
@@ -14,6 +17,16 @@ DbapiColumnDescription: ta.TypeAlias = tuple[
|
|
14
17
|
]
|
15
18
|
|
16
19
|
|
20
|
+
class DbapiColumnDescription_(ta.NamedTuple): # noqa
|
21
|
+
name: str
|
22
|
+
type_code: DbapiTypeCode
|
23
|
+
display_size: int | None
|
24
|
+
internal_size: int | None
|
25
|
+
precision: int | None
|
26
|
+
scale: int | None
|
27
|
+
null_ok: bool | None
|
28
|
+
|
29
|
+
|
17
30
|
class DbapiConnection(ta.Protocol):
|
18
31
|
def close(self) -> object: ...
|
19
32
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
omlish/.manifests.json,sha256=dyIpveH7Z8OnQp2pTn6NVv7LCDXVrozJWAzbk8PBavg,7950
|
2
|
-
omlish/__about__.py,sha256=
|
2
|
+
omlish/__about__.py,sha256=5uwjOU7ezPs6bQf_eJwOpEl8jPeW9UzKUtjquPH_WN4,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
|
@@ -226,9 +226,9 @@ omlish/formats/codecs.py,sha256=ip4TLOyWAaUyEJmrIOzuLMtjRdgaMEsC6JeAlcCVi28,1657
|
|
226
226
|
omlish/formats/dotenv.py,sha256=qoDG4Ayu7B-8LjBBhcmNiLZW0_9LgCi3Ri2aPo9DEQ8,19314
|
227
227
|
omlish/formats/json5.py,sha256=odpZIShlUpv19aACWe58SoMPcv0AHKIa6zSMjlKgaMI,515
|
228
228
|
omlish/formats/pickle.py,sha256=jdp4E9WH9qVPBE3sSqbqDtUo18RbTSIiSpSzJ-IEVZw,529
|
229
|
-
omlish/formats/props.py,sha256=
|
229
|
+
omlish/formats/props.py,sha256=auCv-Jx79KGlWfyG1-Qo0ou-Ex0W_mF3r_lDFdsVkWI,18920
|
230
230
|
omlish/formats/repr.py,sha256=kYrNs4o-ji8nOdp6u_L3aMgBMWN1ZAZJSAWgQQfStSQ,414
|
231
|
-
omlish/formats/xml.py,sha256=
|
231
|
+
omlish/formats/xml.py,sha256=rKXN1RDJV-jliM4fZ2NtmsujB5cAGQBMzRHRHEnH9Ko,2661
|
232
232
|
omlish/formats/yaml.py,sha256=ffOwGnLA6chdiFyaS7X0TBMGmHG9AoGudzKVWfQ1UOs,7389
|
233
233
|
omlish/formats/ini/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
234
234
|
omlish/formats/ini/codec.py,sha256=omuFg0kiDksv8rRlWd_v32ebzEcKlgmiPgGID3bRi2M,631
|
@@ -357,7 +357,7 @@ omlish/iterators/iterators.py,sha256=ghI4dO6WPyyFOLTIIMaHQ_IOy2xXaFpGPqveZ5YGIBU
|
|
357
357
|
omlish/iterators/recipes.py,sha256=53mkexitMhkwXQZbL6DrhpT0WePQ_56uXd5Jaw3DfzI,467
|
358
358
|
omlish/iterators/tools.py,sha256=SvXyyQJh7aceLYhRl6pQB-rfSaXw5IMIWukeEeOZt-0,2492
|
359
359
|
omlish/iterators/unique.py,sha256=0jAX3kwzVfRNhe0Tmh7kVP_Q2WBIn8POo_O-rgFV0rQ,1390
|
360
|
-
omlish/lang/__init__.py,sha256=
|
360
|
+
omlish/lang/__init__.py,sha256=091aYd1gRii-ulxI9QAMjZBPLcl-kfL-XU82kLMR0qU,4013
|
361
361
|
omlish/lang/cached.py,sha256=92TvRZQ6sWlm7dNn4hgl7aWKbX0J1XUEo3DRjBpgVQk,7834
|
362
362
|
omlish/lang/clsdct.py,sha256=AjtIWLlx2E6D5rC97zQ3Lwq2SOMkbg08pdO_AxpzEHI,1744
|
363
363
|
omlish/lang/cmp.py,sha256=5vbzWWbqdzDmNKAGL19z6ZfUKe5Ci49e-Oegf9f4BsE,1346
|
@@ -372,7 +372,7 @@ omlish/lang/iterables.py,sha256=HOjcxOwyI5bBApDLsxRAGGhTTmw7fdZl2kEckxRVl-0,1994
|
|
372
372
|
omlish/lang/maybes.py,sha256=1RN7chX_x2XvgUwryZRz0W7hAX-be3eEFcFub5vvf6M,3417
|
373
373
|
omlish/lang/objects.py,sha256=LOC3JvX1g5hPxJ7Sv2TK9kNkAo9c8J-Jw2NmClR_rkA,4576
|
374
374
|
omlish/lang/resolving.py,sha256=OuN2mDTPNyBUbcrswtvFKtj4xgH4H4WglgqSKv3MTy0,1606
|
375
|
-
omlish/lang/resources.py,sha256=
|
375
|
+
omlish/lang/resources.py,sha256=N64KeVE-rYMxqBBRp91qzgVqpOVR2uX7k1WlS_bo5hM,2681
|
376
376
|
omlish/lang/strings.py,sha256=BsciSYnckD4vGtC6kmtnugR9IN6CIHdcjO4nZu-pSAw,3898
|
377
377
|
omlish/lang/sys.py,sha256=UoZz_PJYVKLQAKqYxxn-LHz1okK_38I__maZgnXMcxU,406
|
378
378
|
omlish/lang/timeouts.py,sha256=vECdWYhc_IZgcal1Ng1Y42wf2FV3KAx-i8As-MgGHIQ,1186
|
@@ -531,7 +531,7 @@ omlish/specs/openapi/__init__.py,sha256=zilQhafjvteRDF_TUIRgF293dBC6g-TJChmUb6T9
|
|
531
531
|
omlish/specs/openapi/marshal.py,sha256=Z-E2Knm04C81N8AA8cibCVSl2ImhSpHZVc7yAhmPx88,2135
|
532
532
|
omlish/specs/openapi/openapi.py,sha256=y4h04jeB7ORJSVrcy7apaBdpwLjIyscv1Ub5SderH2c,12682
|
533
533
|
omlish/sql/__init__.py,sha256=TpZLsEJKJzvJ0eMzuV8hwOJJbkxBCV1RZPUMLAVB6io,173
|
534
|
-
omlish/sql/abc.py,sha256=
|
534
|
+
omlish/sql/abc.py,sha256=NfbcIlEvdEu6vn0TolhfYb2SO5uzUmY0kARCbg6uVAU,1879
|
535
535
|
omlish/sql/dbapi.py,sha256=5ghJH-HexsmDlYdWlhf00nCGQX2IC98_gxIxMkucOas,3195
|
536
536
|
omlish/sql/dbs.py,sha256=lpdFmm2vTwLoBiVYGj9yPsVcTEYYNCxlYZZpjfChzkY,1870
|
537
537
|
omlish/sql/params.py,sha256=Z4VPet6GhNqD1T_MXSWSHkdy3cpUEhST-OplC4B_fYI,4433
|
@@ -609,9 +609,9 @@ omlish/text/indent.py,sha256=YjtJEBYWuk8--b9JU_T6q4yxV85_TR7VEVr5ViRCFwk,1336
|
|
609
609
|
omlish/text/minja.py,sha256=jZC-fp3Xuhx48ppqsf2Sf1pHbC0t8XBB7UpUUoOk2Qw,5751
|
610
610
|
omlish/text/parts.py,sha256=7vPF1aTZdvLVYJ4EwBZVzRSy8XB3YqPd7JwEnNGGAOo,6495
|
611
611
|
omlish/text/random.py,sha256=jNWpqiaKjKyTdMXC-pWAsSC10AAP-cmRRPVhm59ZWLk,194
|
612
|
-
omlish-0.0.0.
|
613
|
-
omlish-0.0.0.
|
614
|
-
omlish-0.0.0.
|
615
|
-
omlish-0.0.0.
|
616
|
-
omlish-0.0.0.
|
617
|
-
omlish-0.0.0.
|
612
|
+
omlish-0.0.0.dev203.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
613
|
+
omlish-0.0.0.dev203.dist-info/METADATA,sha256=21p9UObqpEGCyCoTCTdNVLdZk3MYwxkiG8uZAVs4U5Y,4264
|
614
|
+
omlish-0.0.0.dev203.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
615
|
+
omlish-0.0.0.dev203.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
|
616
|
+
omlish-0.0.0.dev203.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
|
617
|
+
omlish-0.0.0.dev203.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|