omlish 0.0.0.dev364__py3-none-any.whl → 0.0.0.dev366__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.

Potentially problematic release.


This version of omlish might be problematic. Click here for more details.

omlish/__about__.py CHANGED
@@ -1,5 +1,5 @@
1
- __version__ = '0.0.0.dev364'
2
- __revision__ = 'efbc21858b1c3354b55f4666e435a1bd79b1a23a'
1
+ __version__ = '0.0.0.dev366'
2
+ __revision__ = 'c55c3c03ccdc096a29316198acb1ecaa50da5814'
3
3
 
4
4
 
5
5
  #
@@ -60,7 +60,7 @@ class Project(ProjectBase):
60
60
  ],
61
61
 
62
62
  'formats': [
63
- 'orjson ~= 3.10',
63
+ 'orjson ~= 3.11',
64
64
  'ujson ~= 5.10',
65
65
 
66
66
  'pyyaml ~= 6.0',
omlish/manifests/load.py CHANGED
@@ -9,6 +9,7 @@ TODO:
9
9
  import dataclasses as dc
10
10
  import importlib.machinery
11
11
  import importlib.resources
12
+ import importlib.util
12
13
  import json
13
14
  import os.path
14
15
  import threading
@@ -121,18 +122,40 @@ class ManifestLoader:
121
122
 
122
123
  #
123
124
 
125
+ def _read_pkg_file_text(self, pkg_name: str, file_name: str) -> ta.Optional[str]:
126
+ # importlib.resources.files actually imports the package - to avoid this, if possible, the file is read straight
127
+ # off the filesystem.
128
+ spec = importlib.util.find_spec(pkg_name)
129
+ if (
130
+ spec is not None and
131
+ isinstance(spec.loader, importlib.machinery.SourceFileLoader) and
132
+ spec.origin is not None and
133
+ os.path.basename(spec.origin) == '__init__.py' and
134
+ os.path.isfile(spec.origin)
135
+ ):
136
+ file_path = os.path.join(os.path.dirname(spec.origin), file_name)
137
+ if os.path.isfile(file_path):
138
+ with open(file_path, encoding='utf-8') as f:
139
+ return f.read()
140
+
141
+ t = importlib.resources.files(pkg_name).joinpath(file_name)
142
+ if not t.is_file():
143
+ return None
144
+ return t.read_text('utf-8')
145
+
146
+ MANIFESTS_FILE_NAME: ta.ClassVar[str] = '.manifests.json'
147
+
124
148
  def _load_raw(self, pkg_name: str) -> ta.Optional[ta.Sequence[Manifest]]:
125
149
  try:
126
150
  return self._raw_cache[pkg_name]
127
151
  except KeyError:
128
152
  pass
129
153
 
130
- t = importlib.resources.files(pkg_name).joinpath('.manifests.json')
131
- if not t.is_file():
154
+ src = self._read_pkg_file_text(pkg_name, self.MANIFESTS_FILE_NAME)
155
+ if src is None:
132
156
  self._raw_cache[pkg_name] = None
133
157
  return None
134
158
 
135
- src = t.read_text('utf-8')
136
159
  obj = json.loads(src)
137
160
  if not isinstance(obj, (list, tuple)):
138
161
  raise TypeError(obj)
omlish/metadata.py CHANGED
@@ -91,7 +91,15 @@ def append_object_metadata(obj: T, *mds: ObjectMetadata) -> T:
91
91
  return obj
92
92
 
93
93
 
94
- def get_object_metadata(obj: ta.Any, *, strict: bool = False) -> ta.Sequence[ObjectMetadata]:
94
+ _type = type
95
+
96
+
97
+ def get_object_metadata(
98
+ obj: ta.Any,
99
+ *,
100
+ strict: bool = False,
101
+ type: ta.Type | tuple[ta.Type, ...] | None = None, # noqa
102
+ ) -> ta.Sequence[ObjectMetadata]:
95
103
  try:
96
104
  tgt = _unwrap_object_metadata_target(obj)
97
105
  except ObjectMetadataTargetTypeError:
@@ -104,7 +112,12 @@ def get_object_metadata(obj: ta.Any, *, strict: bool = False) -> ta.Sequence[Obj
104
112
  except AttributeError:
105
113
  return ()
106
114
 
107
- return dct.get(_OBJECT_METADATA_ATTR, ())
115
+ ret = dct.get(_OBJECT_METADATA_ATTR, ())
116
+
117
+ if type is not None:
118
+ ret = [o for o in ret if isinstance(o, type)]
119
+
120
+ return ret
108
121
 
109
122
 
110
123
  ##
omlish/os/paths.py CHANGED
@@ -7,6 +7,31 @@ import typing as ta
7
7
  ##
8
8
 
9
9
 
10
+ @ta.overload
11
+ def path_dirname(p: str, n: int = 1) -> str:
12
+ ...
13
+
14
+
15
+ @ta.overload
16
+ def path_dirname(p: bytes, n: int = 1) -> bytes:
17
+ ...
18
+
19
+
20
+ def path_dirname(p, n=1):
21
+ if isinstance(p, bytes):
22
+ sep: ta.Any = b'/'
23
+ else:
24
+ sep = '/'
25
+ p = os.fspath(p)
26
+ i = -1
27
+ for _ in range(n):
28
+ i = p.rindex(sep, 0, i)
29
+ head = p[:i + 1]
30
+ if head and head != sep * len(head):
31
+ head = head.rstrip(sep)
32
+ return head
33
+
34
+
10
35
  def abs_real_path(p: str) -> str:
11
36
  return os.path.abspath(os.path.realpath(p))
12
37
 
omlish/term/confirm.py CHANGED
@@ -15,6 +15,9 @@ def confirm_action(
15
15
  stdin = sys.stdin
16
16
  if not stdin.isatty():
17
17
  raise OSError(f'stdin {stdin!r} is not a tty')
18
+ # FIXME: we want to make sure we only run on a tty, but we als want input()'s readline goodies..
19
+ if stdin is not sys.stdin:
20
+ raise RuntimeError('Unsupported stdin')
18
21
 
19
22
  if stdout is None:
20
23
  stdout = sys.stdout
@@ -37,4 +40,4 @@ def confirm_action(
37
40
  elif c == 'n':
38
41
  return False
39
42
  else:
40
- print("Please enter 'y' for yes or 'n' for no.")
43
+ print("Please enter 'y' for yes or 'n' for no.", file=stdout)
omlish/text/templating.py CHANGED
@@ -1,6 +1,7 @@
1
1
  """
2
2
  TODO:
3
3
  - find_vars
4
+ - some kind of EnvKey / EnvMarker(lang.Marker), namespace-able env keys - but how to weave these into tmpl srcs?
4
5
  """
5
6
  import abc
6
7
  import dataclasses as dc
@@ -23,6 +24,11 @@ else:
23
24
 
24
25
 
25
26
  class Templater(lang.Abstract):
27
+ """
28
+ This is named a 'templatER', not 'template', because it probably refers to a bigger thing itself called a
29
+ 'template' (like a `jinja2.Template`).
30
+ """
31
+
26
32
  @dc.dataclass(frozen=True)
27
33
  class Context:
28
34
  env: ta.Mapping[str, ta.Any] | None = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: omlish
3
- Version: 0.0.0.dev364
3
+ Version: 0.0.0.dev366
4
4
  Summary: omlish
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -25,7 +25,7 @@ Requires-Dist: brotli~=1.1; extra == "all"
25
25
  Requires-Dist: asttokens~=3.0; extra == "all"
26
26
  Requires-Dist: executing~=2.2; extra == "all"
27
27
  Requires-Dist: psutil~=7.0; extra == "all"
28
- Requires-Dist: orjson~=3.10; extra == "all"
28
+ Requires-Dist: orjson~=3.11; extra == "all"
29
29
  Requires-Dist: ujson~=5.10; extra == "all"
30
30
  Requires-Dist: pyyaml~=6.0; extra == "all"
31
31
  Requires-Dist: cbor2~=5.6; extra == "all"
@@ -49,7 +49,7 @@ Requires-Dist: anyio~=4.9; extra == "all"
49
49
  Requires-Dist: sniffio~=1.3; extra == "all"
50
50
  Requires-Dist: asttokens~=3.0; extra == "all"
51
51
  Requires-Dist: executing~=2.2; extra == "all"
52
- Requires-Dist: orjson~=3.10; extra == "all"
52
+ Requires-Dist: orjson~=3.11; extra == "all"
53
53
  Requires-Dist: pyyaml~=6.0; extra == "all"
54
54
  Requires-Dist: wrapt~=1.17; extra == "all"
55
55
  Provides-Extra: async
@@ -68,7 +68,7 @@ Requires-Dist: asttokens~=3.0; extra == "diag"
68
68
  Requires-Dist: executing~=2.2; extra == "diag"
69
69
  Requires-Dist: psutil~=7.0; extra == "diag"
70
70
  Provides-Extra: formats
71
- Requires-Dist: orjson~=3.10; extra == "formats"
71
+ Requires-Dist: orjson~=3.11; extra == "formats"
72
72
  Requires-Dist: ujson~=5.10; extra == "formats"
73
73
  Requires-Dist: pyyaml~=6.0; extra == "formats"
74
74
  Requires-Dist: cbor2~=5.6; extra == "formats"
@@ -100,7 +100,7 @@ Requires-Dist: anyio~=4.9; extra == "plus"
100
100
  Requires-Dist: sniffio~=1.3; extra == "plus"
101
101
  Requires-Dist: asttokens~=3.0; extra == "plus"
102
102
  Requires-Dist: executing~=2.2; extra == "plus"
103
- Requires-Dist: orjson~=3.10; extra == "plus"
103
+ Requires-Dist: orjson~=3.11; extra == "plus"
104
104
  Requires-Dist: pyyaml~=6.0; extra == "plus"
105
105
  Requires-Dist: wrapt~=1.17; extra == "plus"
106
106
  Dynamic: license-file
@@ -1,5 +1,5 @@
1
1
  omlish/.manifests.json,sha256=aT8yZ-Zh-9wfHl5Ym5ouiWC1i0cy7Q7RlhzavB6VLPI,8587
2
- omlish/__about__.py,sha256=jPad_LyUf2h4QZmz7cjzDxV8N2Q7ba3FdRz1o5SXyK0,3478
2
+ omlish/__about__.py,sha256=yGFVJ5HaFgcShdvs7RHmReyCjUqPpQc1naBG93xR4oU,3478
3
3
  omlish/__init__.py,sha256=SsyiITTuK0v74XpKV8dqNaCmjOlan1JZKrHQv5rWKPA,253
4
4
  omlish/c3.py,sha256=rer-TPOFDU6fYq_AWio_AmA-ckZ8JDY5shIzQ_yXfzA,8414
5
5
  omlish/cached.py,sha256=MLap_p0rdGoDIMVhXVHm1tsbcWobJF0OanoodV03Ju8,542
@@ -8,7 +8,7 @@ omlish/datetimes.py,sha256=7dh4aiVRWXWECH3JLF8kkRbgJ1qyGlAlQVp1vCXdTBE,2168
8
8
  omlish/defs.py,sha256=-4UuZoJUUNO_bZ6eSSdhR4CK4NKN2Wwr1FfUvfTF--8,4918
9
9
  omlish/dynamic.py,sha256=zy0oO70_Vlh5dW8Nwav_O9bhIzQ6L16UgSuKR6y43VU,6526
10
10
  omlish/libc.py,sha256=mNY2FWZ2BjSucOx5TEW8IP_B5n84tVZWuVPL3Z3sUH8,15644
11
- omlish/metadata.py,sha256=-noAyXT-7wV0SXul6wV1fPe7EYKxluuuYh1VmM39IPk,3593
11
+ omlish/metadata.py,sha256=l_GGk0g_GkxltQYNDr-P9TTtvIggkdFtnfIffYtaieQ,3797
12
12
  omlish/runmodule.py,sha256=vQ9VZN_c3sQX9rj036dW9lXuMWTjGOfWnwDcWTSWnn0,705
13
13
  omlish/shlex.py,sha256=rlbgHWxjwpkCBRphOPqSIN_KD6qWJMLldNJUILulKT0,253
14
14
  omlish/sync.py,sha256=-2gVJZFl8hvp7jvrnX8GcZVOecqAym6AcyK1QtMR9Ic,2979
@@ -493,7 +493,7 @@ omlish/logs/timing.py,sha256=qsQ3DB6swts1pxrFlmLWQzhH-3nzDrq1MUu7PxjjUyU,1519
493
493
  omlish/logs/utils.py,sha256=OkFWf1exmWImmT7BaSiIC7c0Fk9tAis-PRqo8H4ny3c,398
494
494
  omlish/manifests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
495
495
  omlish/manifests/base.py,sha256=5CmayiuzdXXv9hB5tDnWqfAosAoEQ26YG0B-emkiTXU,941
496
- omlish/manifests/load.py,sha256=XYSWJve4dYSaXNO4vSTv5REB6dqJEy9u-S0hoWOx8ko,6661
496
+ omlish/manifests/load.py,sha256=NLpD8eBz078MNjQ9bEafhbpPBPfM_cVQVnkdmtQv7Gk,7666
497
497
  omlish/manifests/static.py,sha256=7YwOVh_Ek9_aTrWsWNO8kWS10_j4K7yv3TpXZSHsvDY,501
498
498
  omlish/manifests/types.py,sha256=5hQuY-WZ9VMqHZXr-9Dayg380JsnX2vJzXyw6vC6UDs,317
499
499
  omlish/marshal/__init__.py,sha256=QeWqXKb6_Jk8vpX9Z-apWlM3nUbJY3uCPOm0k8Lw8b8,3584
@@ -559,7 +559,7 @@ omlish/os/forkhooks.py,sha256=sLrDCOletKcuiKTKIstksmvYw8GNg5e5yHUGuJ0dEeo,5678
559
559
  omlish/os/journald.py,sha256=Ysm-lyjBfTvRA9PZtkdNxeFNNuSdLwoCXnBgePeRu3Y,3909
560
560
  omlish/os/linux.py,sha256=CfnYR1vJooo74OfeiSB6EaB1KN5SLz9x3b1KXtJIRQ4,18949
561
561
  omlish/os/mangle.py,sha256=1Z_gYNiRiHn7wAA8tGEumra3lD4r9Isn581Ml2auJZI,531
562
- omlish/os/paths.py,sha256=Eok1nx4H3SjO86EroTKRl1upA1VNjgvlwYbR5pGpSO4,855
562
+ omlish/os/paths.py,sha256=lnO2JJWo8rWgmrmNUiRuGyXVWdmfalDsGmH0UsyRsHA,1304
563
563
  omlish/os/signals.py,sha256=k2nSiuefwzjRkqxBf2gZX2QDANDpHHB1Xfsvv49nQHc,358
564
564
  omlish/os/sizes.py,sha256=ohGartgu_us6Eo6qT2pz5MvLeHfMes1Fxq8om_z0cak,157
565
565
  omlish/os/temp.py,sha256=TkiBU89aq0vHHaMKFNEFsKV6F_wTPZJCdnmwvGygD0Q,1209
@@ -742,7 +742,7 @@ omlish/subprocesses/wrap.py,sha256=AhGV8rsnaVUMQCFYKkrjj35fs3O-VJLZC1hZ14dz3C8,7
742
742
  omlish/term/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
743
743
  omlish/term/codes.py,sha256=fDRhUYzCzllcvCfMMgEroJaQoxqFsfTivpYdVmnwcCE,6390
744
744
  omlish/term/coloring.py,sha256=MCFYV_JTvEObTCJE12wfalW8OFFQB_KIFBKDtfES6Nk,2559
745
- omlish/term/confirm.py,sha256=5aqZnfy60K9CBSfXDsD-zA84HJm5fBWb_Y1T1x8gRnw,918
745
+ omlish/term/confirm.py,sha256=M3DAyyPO2yREhSXOAWF-KQcLTHRRZCVsg2nrIKT8kHI,1111
746
746
  omlish/term/progressbar.py,sha256=em2o2emwbfmJIB-EHljQBCkwHd-Zw8Zydl3n73IYvX0,3678
747
747
  omlish/term/vt100/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
748
748
  omlish/term/vt100/c.py,sha256=93HARU6Dd1rVF-n8cAyXqkEqleYLcofuLgSUNd6-GbU,3537
@@ -791,7 +791,7 @@ omlish/text/mangle.py,sha256=k7mYavVgxJ2ENV2wfjw3c9u3hqH5NeVpjoxYbyaYC0Y,2796
791
791
  omlish/text/minja.py,sha256=eyOA_zUCzyqaBfiPX-hV2xdK9_cqlDEhbVTkZUTZgQo,7521
792
792
  omlish/text/parts.py,sha256=MpiCUyfpcL4PLb2Etj8V7Yj4qofhy0xVwBrIL6RfNdg,6646
793
793
  omlish/text/random.py,sha256=8feS5JE_tSjYlMl-lp0j93kCfzBae9AM2cXlRLebXMA,199
794
- omlish/text/templating.py,sha256=4dw0EGEPze6AtI6767PVvwnU3Vn9nyl6NI-ieqY7wQ0,3041
794
+ omlish/text/templating.py,sha256=Nf5BVDgrYBf0WmYwV6SnHPDvl9XVMu8v7MX78pInLTw,3325
795
795
  omlish/text/antlr/__init__.py,sha256=88bMl_28cfSKslgOkMGYXqALgsHz3KC4LFvAVtzj7k8,89
796
796
  omlish/text/antlr/delimit.py,sha256=wvpZ-FlVoGwRjBALKT1in9cIriIwvyFqmHxgliNJEi8,3472
797
797
  omlish/text/antlr/dot.py,sha256=-WHO-xDSv-Ir00TZ4sVIwunKYtZkRveaQ4m5FKj_bRs,962
@@ -872,9 +872,9 @@ omlish/typedvalues/marshal.py,sha256=AtBz7Jq-BfW8vwM7HSxSpR85JAXmxK2T0xDblmm1HI0
872
872
  omlish/typedvalues/of_.py,sha256=UXkxSj504WI2UrFlqdZJbu2hyDwBhL7XVrc2qdR02GQ,1309
873
873
  omlish/typedvalues/reflect.py,sha256=PAvKW6T4cW7u--iX80w3HWwZUS3SmIZ2_lQjT65uAyk,1026
874
874
  omlish/typedvalues/values.py,sha256=ym46I-q2QJ_6l4UlERqv3yj87R-kp8nCKMRph0xQ3UA,1307
875
- omlish-0.0.0.dev364.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
876
- omlish-0.0.0.dev364.dist-info/METADATA,sha256=ZOYVCoR87JVc1QxFTVZMhgI4L5a_nQN_HgZiDLraDY4,4416
877
- omlish-0.0.0.dev364.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
878
- omlish-0.0.0.dev364.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
879
- omlish-0.0.0.dev364.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
880
- omlish-0.0.0.dev364.dist-info/RECORD,,
875
+ omlish-0.0.0.dev366.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
876
+ omlish-0.0.0.dev366.dist-info/METADATA,sha256=y2efGFNp_VAZoZcZx_Pq7FYHst4s70iopzDtnyHK-F0,4416
877
+ omlish-0.0.0.dev366.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
878
+ omlish-0.0.0.dev366.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
879
+ omlish-0.0.0.dev366.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
880
+ omlish-0.0.0.dev366.dist-info/RECORD,,