ominfra 0.0.0.dev146__py3-none-any.whl → 0.0.0.dev148__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1434,7 +1434,10 @@ def parse_octal(arg: ta.Union[str, int]) -> int:
1434
1434
  # ../../../omlish/lite/cached.py
1435
1435
 
1436
1436
 
1437
- class _cached_nullary: # noqa
1437
+ ##
1438
+
1439
+
1440
+ class _AbstractCachedNullary:
1438
1441
  def __init__(self, fn):
1439
1442
  super().__init__()
1440
1443
  self._fn = fn
@@ -1442,17 +1445,25 @@ class _cached_nullary: # noqa
1442
1445
  functools.update_wrapper(self, fn)
1443
1446
 
1444
1447
  def __call__(self, *args, **kwargs): # noqa
1445
- if self._value is self._missing:
1446
- self._value = self._fn()
1447
- return self._value
1448
+ raise TypeError
1448
1449
 
1449
1450
  def __get__(self, instance, owner): # noqa
1450
1451
  bound = instance.__dict__[self._fn.__name__] = self.__class__(self._fn.__get__(instance, owner))
1451
1452
  return bound
1452
1453
 
1453
1454
 
1455
+ ##
1456
+
1457
+
1458
+ class _CachedNullary(_AbstractCachedNullary):
1459
+ def __call__(self, *args, **kwargs): # noqa
1460
+ if self._value is self._missing:
1461
+ self._value = self._fn()
1462
+ return self._value
1463
+
1464
+
1454
1465
  def cached_nullary(fn): # ta.Callable[..., T]) -> ta.Callable[..., T]:
1455
- return _cached_nullary(fn)
1466
+ return _CachedNullary(fn)
1456
1467
 
1457
1468
 
1458
1469
  def static_init(fn: CallableT) -> CallableT:
@@ -1461,6 +1472,20 @@ def static_init(fn: CallableT) -> CallableT:
1461
1472
  return fn
1462
1473
 
1463
1474
 
1475
+ ##
1476
+
1477
+
1478
+ class _AsyncCachedNullary(_AbstractCachedNullary):
1479
+ async def __call__(self, *args, **kwargs):
1480
+ if self._value is self._missing:
1481
+ self._value = await self._fn()
1482
+ return self._value
1483
+
1484
+
1485
+ def async_cached_nullary(fn): # ta.Callable[..., T]) -> ta.Callable[..., T]:
1486
+ return _AsyncCachedNullary(fn)
1487
+
1488
+
1464
1489
  ########################################
1465
1490
  # ../../../omlish/lite/check.py
1466
1491
 
@@ -5183,6 +5208,33 @@ def check_runtime_version() -> None:
5183
5208
  # ../../configs.py
5184
5209
 
5185
5210
 
5211
+ def parse_config_file(
5212
+ name: str,
5213
+ f: ta.TextIO,
5214
+ ) -> ConfigMapping:
5215
+ if name.endswith('.toml'):
5216
+ return toml_loads(f.read())
5217
+
5218
+ elif any(name.endswith(e) for e in ('.yml', '.yaml')):
5219
+ yaml = __import__('yaml')
5220
+ return yaml.safe_load(f)
5221
+
5222
+ elif name.endswith('.ini'):
5223
+ import configparser
5224
+ cp = configparser.ConfigParser()
5225
+ cp.read_file(f)
5226
+ config_dct: ta.Dict[str, ta.Any] = {}
5227
+ for sec in cp.sections():
5228
+ cd = config_dct
5229
+ for k in sec.split('.'):
5230
+ cd = cd.setdefault(k, {})
5231
+ cd.update(cp.items(sec))
5232
+ return config_dct
5233
+
5234
+ else:
5235
+ return json.loads(f.read())
5236
+
5237
+
5186
5238
  def read_config_file(
5187
5239
  path: str,
5188
5240
  cls: ta.Type[T],
@@ -5190,13 +5242,10 @@ def read_config_file(
5190
5242
  prepare: ta.Optional[ta.Callable[[ConfigMapping], ConfigMapping]] = None,
5191
5243
  ) -> T:
5192
5244
  with open(path) as cf:
5193
- if path.endswith('.toml'):
5194
- config_dct = toml_loads(cf.read())
5195
- else:
5196
- config_dct = json.loads(cf.read())
5245
+ config_dct = parse_config_file(os.path.basename(path), cf)
5197
5246
 
5198
5247
  if prepare is not None:
5199
- config_dct = prepare(config_dct) # type: ignore
5248
+ config_dct = prepare(config_dct)
5200
5249
 
5201
5250
  return unmarshal_obj(config_dct, cls)
5202
5251
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ominfra
3
- Version: 0.0.0.dev146
3
+ Version: 0.0.0.dev148
4
4
  Summary: ominfra
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -12,8 +12,8 @@ Classifier: Operating System :: OS Independent
12
12
  Classifier: Operating System :: POSIX
13
13
  Requires-Python: >=3.12
14
14
  License-File: LICENSE
15
- Requires-Dist: omdev==0.0.0.dev146
16
- Requires-Dist: omlish==0.0.0.dev146
15
+ Requires-Dist: omdev==0.0.0.dev148
16
+ Requires-Dist: omlish==0.0.0.dev148
17
17
  Provides-Extra: all
18
18
  Requires-Dist: paramiko~=3.5; extra == "all"
19
19
  Requires-Dist: asyncssh~=2.18; extra == "all"
@@ -2,8 +2,8 @@ ominfra/.manifests.json,sha256=8KREXxMAlsilZOktXPYru1ND3V5hFI22vnrp6hT3bio,589
2
2
  ominfra/__about__.py,sha256=6i1AoruFYQCd-PyhhbDQDWY2d1tiQu9nkwWr-fXAqfY,705
3
3
  ominfra/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  ominfra/cmds.py,sha256=E0AfnvEmnKntXWvmLW5L05_NeDpBET1VBXn7vV6EwBQ,2083
5
- ominfra/configs.py,sha256=8aU1Qmbr-qjaE2iP3gAbA2SWJYMPZ-uGK007L01PoOI,1727
6
- ominfra/pyremote.py,sha256=PEKQP8CtJVyKWgDJ-FYcGxpxOPy2AYOZCOQRBFktg4E,14248
5
+ ominfra/configs.py,sha256=5FTps4LfMld229N6um_jxPGQuzktjXIY9ebJ3zOWbXE,2353
6
+ ominfra/pyremote.py,sha256=Q40eRMfJc5MVscI0grfeNAf1hj4R_8V3ceKQZhKKEII,15025
7
7
  ominfra/ssh.py,sha256=jQpc4WvkMckIfk4vILda8zFaeharRqc_6wxW50b0OjQ,5431
8
8
  ominfra/threadworkers.py,sha256=oX4ubZn7h932saXpRIJu2MNhBExgGGMuGhdXarZxLJw,4948
9
9
  ominfra/clouds/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -33,30 +33,32 @@ ominfra/manage/bootstrap.py,sha256=puGpmK6b6ZCAX5E_HI9ucUuWlXB4U_4Xwc2x8GAKSVo,2
33
33
  ominfra/manage/bootstrap_.py,sha256=WVry3P5ViPpdEC_-EFBouZTECMxs4CwRbek4Oz_iRbc,517
34
34
  ominfra/manage/config.py,sha256=1y2N_8nXHBZc6YbW6BaRZoDDCTBmiHuWtTOQ7zdr5VE,184
35
35
  ominfra/manage/inject.py,sha256=jGjGqlecpxzpJR3-RqQhEBOmpsix5UwSsvrz5DbayC4,1395
36
- ominfra/manage/main.py,sha256=t22pQDv6SmzyF74kukPPgkBKw88e78iHhbiOuClLi98,3034
36
+ ominfra/manage/main.py,sha256=hTsyeukcCrLkdpduGlBN7rogdKoCddKRlWRh2V64Ixo,3502
37
37
  ominfra/manage/marshal.py,sha256=WKj7IU9bo4fBMSSzT6ZMm_WFalXIJZ-V7j8oi92fNhk,305
38
38
  ominfra/manage/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
- ominfra/manage/commands/base.py,sha256=yhOAh893iJrk0SvgkRZQMLw8cvStEI2IaHKP9Ifg7N0,3966
40
- ominfra/manage/commands/execution.py,sha256=F5SUv3SYFwpnDKaBDgSmXLtk7qDSrN7zT0Ri-j1fTNQ,606
41
- ominfra/manage/commands/inject.py,sha256=7_j5UZDqZ5PxFZtFidOprEMEeyF2ocQ5x9Lz6PArACU,3539
42
- ominfra/manage/commands/interp.py,sha256=LjI5kGog2pL5cCdInUTXrtpOpOHeLXaqIi6OjkxU7vE,1031
39
+ ominfra/manage/commands/base.py,sha256=54OP5snMusLGSd5_8qsqNgyfmfPdq23HAV93xRsEJ_4,4004
40
+ ominfra/manage/commands/execution.py,sha256=BJyAIOJx7dG8x4T75vIMpE_hEJCPPnfIkebXpQulSNE,618
41
+ ominfra/manage/commands/inject.py,sha256=yyIR0qQaXw_BXEnl8vZZiVkfilZNyyHHbJ44AHTMUi4,3553
42
+ ominfra/manage/commands/interp.py,sha256=iZLGueK3CRdvdDEQua34SmroEJ3OavU8QCIDqpEo5Y0,1043
43
43
  ominfra/manage/commands/marshal.py,sha256=4DSCMPzRiRhufIB_9DPL6LrZkRZOle5ruOWU4MVlcXM,694
44
- ominfra/manage/commands/subprocess.py,sha256=G8RsYStwbZRnhDyFYMwn4qBT2R7l8vC0hr1KqbXfwDo,2217
44
+ ominfra/manage/commands/subprocess.py,sha256=8-TU5Vuy0ZwymKV0yDgbeLy87ceI3JTK9-2zUK8w15s,2594
45
45
  ominfra/manage/deploy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
- ominfra/manage/deploy/command.py,sha256=XW7NlqNtUYMQuWgQdI8rsCJ-bE1A5odZgbTaYgX-uyI,559
46
+ ominfra/manage/deploy/command.py,sha256=CBzsw31u86wxkY9Ms-Es70ijD_3naZLAcj3Gb6OfGeQ,565
47
47
  ominfra/manage/deploy/inject.py,sha256=j5LYK5y_nZgdaNLde8sV2w_---GvmibgO_ZBT8qzeFM,499
48
48
  ominfra/manage/deploy/paths.py,sha256=3oQEDrdv92WjgH6DQNqTTm9udyvh614aVDGS_9Ter_Q,3848
49
49
  ominfra/manage/remote/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
- ominfra/manage/remote/channel.py,sha256=fWpztlnTmqmg8Yc5kP_YjfeOA3xbB39ejPyh_yYgC0w,1635
51
- ominfra/manage/remote/config.py,sha256=yMJsz8zB5i3ytiS-YaCb6-qXumMKXh18SjmtzPVO44c,280
52
- ominfra/manage/remote/execution.py,sha256=c0V1DxuYew7gY1w6_XPFQ6Ewln4u0cs5j7bK6c3w6ek,6188
53
- ominfra/manage/remote/inject.py,sha256=0TEODiCirwlApejbAR7-0ZGkNXA99IHZdmAFKliyJYw,783
50
+ ominfra/manage/remote/_main.py,sha256=Cg312nrFOsqNBXmrwxNl07SRyqr1ZsSHYyZBITJzFrU,4408
51
+ ominfra/manage/remote/channel.py,sha256=36xR9Ti9ZA8TUBtxmY0u7_3Lv7E6wzQTxlZl7gLR5GE,2224
52
+ ominfra/manage/remote/config.py,sha256=zRIC7Yhh3FMfoIgyqlbDTwpL_jS23lhQXjGB2_YG4Eg,473
53
+ ominfra/manage/remote/connection.py,sha256=5h-JrMK07Ulqgol3ZXmcTpSUr6iMu1oZd-wCjnRqe_Y,2821
54
+ ominfra/manage/remote/execution.py,sha256=jMaWVlA2_zFs8lWPjXWB5-C-oQ1Wk-QH2POXgjIdXx4,9513
55
+ ominfra/manage/remote/inject.py,sha256=euI9YmLTmNw7tdkQq_5PtFg6n9pYz3mGukOOApdYwfg,1076
54
56
  ominfra/manage/remote/payload.py,sha256=Rn-Yo26POpHEOOfUHX3jWkqcQVEAvkJ_5Bu13jwoob4,944
55
- ominfra/manage/remote/spawning.py,sha256=6JLs_IsMjNQr6i8vROUjHsqmNFno1Ykh3oBXOOHBFYY,2614
57
+ ominfra/manage/remote/spawning.py,sha256=xE-as45fCtu3W1q-X6ktYesksdY_uGSQo7gGHX3DxCQ,3214
56
58
  ominfra/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
- ominfra/scripts/journald2aws.py,sha256=7Ic0XYVJYqfqd8JYZB8HlNRMPqt6A1lV1XWMeHqWSaQ,136036
58
- ominfra/scripts/manage.py,sha256=I-uys09OrYWB3mOVDi2fztaPcHtF-WjaL1AtVYHSAI0,151349
59
- ominfra/scripts/supervisor.py,sha256=DZ3V4UI9xAz1tGRrAa-tXNnlr0YqpmRDg8XRvB1r-AE,250082
59
+ ominfra/scripts/journald2aws.py,sha256=B4U4gjE-1TGB3zpizBQEQdu8vvxyId0Psqt_x3GmHhQ,138342
60
+ ominfra/scripts/manage.py,sha256=6_DqMbL3YQl5iTCGypwnDOF87bG5v5LKlaNv97VBVHI,176130
61
+ ominfra/scripts/supervisor.py,sha256=eG6PxnhyGv-R0OCKpb1k36SS0zoepDtlE_4hYUqlHJA,251153
60
62
  ominfra/supervisor/LICENSE.txt,sha256=yvqaMNsDhWxziHa9ien6qCW1SkZv-DQlAg96XjfSee8,1746
61
63
  ominfra/supervisor/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
62
64
  ominfra/supervisor/__main__.py,sha256=I0yFw-C08OOiZ3BF6lF1Oiv789EQXu-_j6whDhQUTEA,66
@@ -98,9 +100,9 @@ ominfra/tailscale/api.py,sha256=C5-t_b6jZXUWcy5k8bXm7CFnk73pSdrlMOgGDeGVrpw,1370
98
100
  ominfra/tailscale/cli.py,sha256=DSGp4hn5xwOW-l_u_InKlSF6kIobxtUtVssf_73STs0,3567
99
101
  ominfra/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
100
102
  ominfra/tools/listresources.py,sha256=4qVg5txsb10EHhvqXXeM6gJ2jx9LbroEnPydDv1uXs0,6176
101
- ominfra-0.0.0.dev146.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
102
- ominfra-0.0.0.dev146.dist-info/METADATA,sha256=qLZjjDSh8MPUSJEMaXe56PZrUyV9-xGCNkyJD0ayYKA,731
103
- ominfra-0.0.0.dev146.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
104
- ominfra-0.0.0.dev146.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
105
- ominfra-0.0.0.dev146.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
106
- ominfra-0.0.0.dev146.dist-info/RECORD,,
103
+ ominfra-0.0.0.dev148.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
104
+ ominfra-0.0.0.dev148.dist-info/METADATA,sha256=1Fq_9kyyKu_ruQylicwWg_zl1wKlwFUwbqW-NpNpfs8,731
105
+ ominfra-0.0.0.dev148.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
106
+ ominfra-0.0.0.dev148.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
107
+ ominfra-0.0.0.dev148.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
108
+ ominfra-0.0.0.dev148.dist-info/RECORD,,