omlish 0.0.0.dev365__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.dev365'
2
- __revision__ = 'b4c28dd8f673c9f03dee99119cd46e8afb3a89f5'
1
+ __version__ = '0.0.0.dev366'
2
+ __revision__ = 'c55c3c03ccdc096a29316198acb1ecaa50da5814'
3
3
 
4
4
 
5
5
  #
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/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
@@ -27,6 +28,7 @@ class Templater(lang.Abstract):
27
28
  This is named a 'templatER', not 'template', because it probably refers to a bigger thing itself called a
28
29
  'template' (like a `jinja2.Template`).
29
30
  """
31
+
30
32
  @dc.dataclass(frozen=True)
31
33
  class Context:
32
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.dev365
3
+ Version: 0.0.0.dev366
4
4
  Summary: omlish
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  omlish/.manifests.json,sha256=aT8yZ-Zh-9wfHl5Ym5ouiWC1i0cy7Q7RlhzavB6VLPI,8587
2
- omlish/__about__.py,sha256=yal4M4IqqPRxe1zOQ3JquQPYH2qkVC_vQZaBVdeABYs,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
@@ -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
@@ -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=dUPLXMFFzI2Ep5OhX13z4QXtnhzgNqOmyLkgF5MlFsg,3210
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.dev365.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
876
- omlish-0.0.0.dev365.dist-info/METADATA,sha256=Iqpr1GKfPFRx-BkzrXQ705YfawXtfqbtyuiCHFm9lxQ,4416
877
- omlish-0.0.0.dev365.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
878
- omlish-0.0.0.dev365.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
879
- omlish-0.0.0.dev365.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
880
- omlish-0.0.0.dev365.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,,