ominfra 0.0.0.dev173__py3-none-any.whl → 0.0.0.dev174__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.
@@ -1450,6 +1450,9 @@ log = logging.getLogger(__name__)
1450
1450
  # ../../../../../omlish/lite/reflect.py
1451
1451
 
1452
1452
 
1453
+ ##
1454
+
1455
+
1453
1456
  _GENERIC_ALIAS_TYPES = (
1454
1457
  ta._GenericAlias, # type: ignore # noqa
1455
1458
  *([ta._SpecialGenericAlias] if hasattr(ta, '_SpecialGenericAlias') else []), # noqa
@@ -1467,6 +1470,9 @@ is_union_alias = functools.partial(is_generic_alias, origin=ta.Union)
1467
1470
  is_callable_alias = functools.partial(is_generic_alias, origin=ta.Callable)
1468
1471
 
1469
1472
 
1473
+ ##
1474
+
1475
+
1470
1476
  def is_optional_alias(spec: ta.Any) -> bool:
1471
1477
  return (
1472
1478
  isinstance(spec, _GENERIC_ALIAS_TYPES) and # noqa
@@ -1481,6 +1487,9 @@ def get_optional_alias_arg(spec: ta.Any) -> ta.Any:
1481
1487
  return it
1482
1488
 
1483
1489
 
1490
+ ##
1491
+
1492
+
1484
1493
  def is_new_type(spec: ta.Any) -> bool:
1485
1494
  if isinstance(ta.NewType, type):
1486
1495
  return isinstance(spec, ta.NewType)
@@ -1493,6 +1502,26 @@ def get_new_type_supertype(spec: ta.Any) -> ta.Any:
1493
1502
  return spec.__supertype__
1494
1503
 
1495
1504
 
1505
+ ##
1506
+
1507
+
1508
+ def is_literal_type(spec: ta.Any) -> bool:
1509
+ if hasattr(ta, '_LiteralGenericAlias'):
1510
+ return isinstance(spec, ta._LiteralGenericAlias) # noqa
1511
+ else:
1512
+ return (
1513
+ isinstance(spec, ta._GenericAlias) and # type: ignore # noqa
1514
+ spec.__origin__ is ta.Literal
1515
+ )
1516
+
1517
+
1518
+ def get_literal_type_args(spec: ta.Any) -> ta.Iterable[ta.Any]:
1519
+ return spec.__args__
1520
+
1521
+
1522
+ ##
1523
+
1524
+
1496
1525
  def deep_subclasses(cls: ta.Type[T]) -> ta.Iterator[ta.Type[T]]:
1497
1526
  seen = set()
1498
1527
  todo = list(reversed(cls.__subclasses__()))
@@ -2600,6 +2629,18 @@ class OptionalObjMarshaler(ObjMarshaler):
2600
2629
  return self.item.unmarshal(o, ctx)
2601
2630
 
2602
2631
 
2632
+ @dc.dataclass(frozen=True)
2633
+ class LiteralObjMarshaler(ObjMarshaler):
2634
+ item: ObjMarshaler
2635
+ vs: frozenset
2636
+
2637
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2638
+ return self.item.marshal(check.in_(o, self.vs), ctx)
2639
+
2640
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2641
+ return check.in_(self.item.unmarshal(o, ctx), self.vs)
2642
+
2643
+
2603
2644
  @dc.dataclass(frozen=True)
2604
2645
  class MappingObjMarshaler(ObjMarshaler):
2605
2646
  ty: type
@@ -2811,6 +2852,11 @@ class ObjMarshalerManager:
2811
2852
  if is_new_type(ty):
2812
2853
  return rec(get_new_type_supertype(ty))
2813
2854
 
2855
+ if is_literal_type(ty):
2856
+ lvs = frozenset(get_literal_type_args(ty))
2857
+ lty = check.single(set(map(type, lvs)))
2858
+ return LiteralObjMarshaler(rec(lty), lvs)
2859
+
2814
2860
  if is_generic_alias(ty):
2815
2861
  try:
2816
2862
  mt = self._generic_mapping_types[ta.get_origin(ty)]
ominfra/scripts/manage.py CHANGED
@@ -2667,6 +2667,9 @@ def pycharm_debug_preamble(prd: PycharmRemoteDebug) -> str:
2667
2667
  # ../../../omlish/lite/reflect.py
2668
2668
 
2669
2669
 
2670
+ ##
2671
+
2672
+
2670
2673
  _GENERIC_ALIAS_TYPES = (
2671
2674
  ta._GenericAlias, # type: ignore # noqa
2672
2675
  *([ta._SpecialGenericAlias] if hasattr(ta, '_SpecialGenericAlias') else []), # noqa
@@ -2684,6 +2687,9 @@ is_union_alias = functools.partial(is_generic_alias, origin=ta.Union)
2684
2687
  is_callable_alias = functools.partial(is_generic_alias, origin=ta.Callable)
2685
2688
 
2686
2689
 
2690
+ ##
2691
+
2692
+
2687
2693
  def is_optional_alias(spec: ta.Any) -> bool:
2688
2694
  return (
2689
2695
  isinstance(spec, _GENERIC_ALIAS_TYPES) and # noqa
@@ -2698,6 +2704,9 @@ def get_optional_alias_arg(spec: ta.Any) -> ta.Any:
2698
2704
  return it
2699
2705
 
2700
2706
 
2707
+ ##
2708
+
2709
+
2701
2710
  def is_new_type(spec: ta.Any) -> bool:
2702
2711
  if isinstance(ta.NewType, type):
2703
2712
  return isinstance(spec, ta.NewType)
@@ -2710,6 +2719,26 @@ def get_new_type_supertype(spec: ta.Any) -> ta.Any:
2710
2719
  return spec.__supertype__
2711
2720
 
2712
2721
 
2722
+ ##
2723
+
2724
+
2725
+ def is_literal_type(spec: ta.Any) -> bool:
2726
+ if hasattr(ta, '_LiteralGenericAlias'):
2727
+ return isinstance(spec, ta._LiteralGenericAlias) # noqa
2728
+ else:
2729
+ return (
2730
+ isinstance(spec, ta._GenericAlias) and # type: ignore # noqa
2731
+ spec.__origin__ is ta.Literal
2732
+ )
2733
+
2734
+
2735
+ def get_literal_type_args(spec: ta.Any) -> ta.Iterable[ta.Any]:
2736
+ return spec.__args__
2737
+
2738
+
2739
+ ##
2740
+
2741
+
2713
2742
  def deep_subclasses(cls: ta.Type[T]) -> ta.Iterator[ta.Type[T]]:
2714
2743
  seen = set()
2715
2744
  todo = list(reversed(cls.__subclasses__()))
@@ -6049,6 +6078,18 @@ class OptionalObjMarshaler(ObjMarshaler):
6049
6078
  return self.item.unmarshal(o, ctx)
6050
6079
 
6051
6080
 
6081
+ @dc.dataclass(frozen=True)
6082
+ class LiteralObjMarshaler(ObjMarshaler):
6083
+ item: ObjMarshaler
6084
+ vs: frozenset
6085
+
6086
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
6087
+ return self.item.marshal(check.in_(o, self.vs), ctx)
6088
+
6089
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
6090
+ return check.in_(self.item.unmarshal(o, ctx), self.vs)
6091
+
6092
+
6052
6093
  @dc.dataclass(frozen=True)
6053
6094
  class MappingObjMarshaler(ObjMarshaler):
6054
6095
  ty: type
@@ -6260,6 +6301,11 @@ class ObjMarshalerManager:
6260
6301
  if is_new_type(ty):
6261
6302
  return rec(get_new_type_supertype(ty))
6262
6303
 
6304
+ if is_literal_type(ty):
6305
+ lvs = frozenset(get_literal_type_args(ty))
6306
+ lty = check.single(set(map(type, lvs)))
6307
+ return LiteralObjMarshaler(rec(lty), lvs)
6308
+
6263
6309
  if is_generic_alias(ty):
6264
6310
  try:
6265
6311
  mt = self._generic_mapping_types[ta.get_origin(ty)]
@@ -2259,6 +2259,9 @@ Maybe._empty = tuple.__new__(_Maybe, ()) # noqa
2259
2259
  # ../../../omlish/lite/reflect.py
2260
2260
 
2261
2261
 
2262
+ ##
2263
+
2264
+
2262
2265
  _GENERIC_ALIAS_TYPES = (
2263
2266
  ta._GenericAlias, # type: ignore # noqa
2264
2267
  *([ta._SpecialGenericAlias] if hasattr(ta, '_SpecialGenericAlias') else []), # noqa
@@ -2276,6 +2279,9 @@ is_union_alias = functools.partial(is_generic_alias, origin=ta.Union)
2276
2279
  is_callable_alias = functools.partial(is_generic_alias, origin=ta.Callable)
2277
2280
 
2278
2281
 
2282
+ ##
2283
+
2284
+
2279
2285
  def is_optional_alias(spec: ta.Any) -> bool:
2280
2286
  return (
2281
2287
  isinstance(spec, _GENERIC_ALIAS_TYPES) and # noqa
@@ -2290,6 +2296,9 @@ def get_optional_alias_arg(spec: ta.Any) -> ta.Any:
2290
2296
  return it
2291
2297
 
2292
2298
 
2299
+ ##
2300
+
2301
+
2293
2302
  def is_new_type(spec: ta.Any) -> bool:
2294
2303
  if isinstance(ta.NewType, type):
2295
2304
  return isinstance(spec, ta.NewType)
@@ -2302,6 +2311,26 @@ def get_new_type_supertype(spec: ta.Any) -> ta.Any:
2302
2311
  return spec.__supertype__
2303
2312
 
2304
2313
 
2314
+ ##
2315
+
2316
+
2317
+ def is_literal_type(spec: ta.Any) -> bool:
2318
+ if hasattr(ta, '_LiteralGenericAlias'):
2319
+ return isinstance(spec, ta._LiteralGenericAlias) # noqa
2320
+ else:
2321
+ return (
2322
+ isinstance(spec, ta._GenericAlias) and # type: ignore # noqa
2323
+ spec.__origin__ is ta.Literal
2324
+ )
2325
+
2326
+
2327
+ def get_literal_type_args(spec: ta.Any) -> ta.Iterable[ta.Any]:
2328
+ return spec.__args__
2329
+
2330
+
2331
+ ##
2332
+
2333
+
2305
2334
  def deep_subclasses(cls: ta.Type[T]) -> ta.Iterator[ta.Type[T]]:
2306
2335
  seen = set()
2307
2336
  todo = list(reversed(cls.__subclasses__()))
@@ -4991,6 +5020,18 @@ class OptionalObjMarshaler(ObjMarshaler):
4991
5020
  return self.item.unmarshal(o, ctx)
4992
5021
 
4993
5022
 
5023
+ @dc.dataclass(frozen=True)
5024
+ class LiteralObjMarshaler(ObjMarshaler):
5025
+ item: ObjMarshaler
5026
+ vs: frozenset
5027
+
5028
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
5029
+ return self.item.marshal(check.in_(o, self.vs), ctx)
5030
+
5031
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
5032
+ return check.in_(self.item.unmarshal(o, ctx), self.vs)
5033
+
5034
+
4994
5035
  @dc.dataclass(frozen=True)
4995
5036
  class MappingObjMarshaler(ObjMarshaler):
4996
5037
  ty: type
@@ -5202,6 +5243,11 @@ class ObjMarshalerManager:
5202
5243
  if is_new_type(ty):
5203
5244
  return rec(get_new_type_supertype(ty))
5204
5245
 
5246
+ if is_literal_type(ty):
5247
+ lvs = frozenset(get_literal_type_args(ty))
5248
+ lty = check.single(set(map(type, lvs)))
5249
+ return LiteralObjMarshaler(rec(lty), lvs)
5250
+
5205
5251
  if is_generic_alias(ty):
5206
5252
  try:
5207
5253
  mt = self._generic_mapping_types[ta.get_origin(ty)]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ominfra
3
- Version: 0.0.0.dev173
3
+ Version: 0.0.0.dev174
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.dev173
16
- Requires-Dist: omlish==0.0.0.dev173
15
+ Requires-Dist: omdev==0.0.0.dev174
16
+ Requires-Dist: omlish==0.0.0.dev174
17
17
  Provides-Extra: all
18
18
  Requires-Dist: paramiko~=3.5; extra == "all"
19
19
  Requires-Dist: asyncssh~=2.18; extra == "all"
@@ -85,9 +85,9 @@ ominfra/manage/targets/connection.py,sha256=rVI1YJxFClcF-sdttqWyIz9_XjPI01GUdwxY
85
85
  ominfra/manage/targets/inject.py,sha256=P4597xWM-V3I_gCt2O71OLhYQkkXtuJvkYRsIbhhMcE,1561
86
86
  ominfra/manage/targets/targets.py,sha256=7GP6UAZyJFEhpkJN6UQdpr_WN3p7C76v-s445y-WB6U,1885
87
87
  ominfra/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
88
- ominfra/scripts/journald2aws.py,sha256=OjbemVx-zyCBuWZVgTky66n2-MfyyS7ups4A9hsvHfA,155684
89
- ominfra/scripts/manage.py,sha256=Fx8aura2aZJW6qItOIamFcB028hoxhBgt3dvtkSCFoM,315670
90
- ominfra/scripts/supervisor.py,sha256=viYrsafRW5fLN2KUS1MtxCOm9CO4iOgIu60cmN3joSg,274450
88
+ ominfra/scripts/journald2aws.py,sha256=fbs8jZCsnwi5vF8Bg892wu3rscHCHeLQlvsDs6oAZBs,156681
89
+ ominfra/scripts/manage.py,sha256=jzClDt2zLKySdtAvo1vvis8bJaYVY44KB_jZ6ePY4ho,316667
90
+ ominfra/scripts/supervisor.py,sha256=CD8o9RktPyB3L8nMBa6rabWE0tZlti6dmzoEEKRPWvY,275447
91
91
  ominfra/supervisor/LICENSE.txt,sha256=yvqaMNsDhWxziHa9ien6qCW1SkZv-DQlAg96XjfSee8,1746
92
92
  ominfra/supervisor/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
93
93
  ominfra/supervisor/__main__.py,sha256=I0yFw-C08OOiZ3BF6lF1Oiv789EQXu-_j6whDhQUTEA,66
@@ -129,9 +129,9 @@ ominfra/tailscale/api.py,sha256=C5-t_b6jZXUWcy5k8bXm7CFnk73pSdrlMOgGDeGVrpw,1370
129
129
  ominfra/tailscale/cli.py,sha256=h6akQJMl0KuWLHS7Ur6WcBZ2JwF0DJQhsPTnFBdGyNk,3571
130
130
  ominfra/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
131
131
  ominfra/tools/listresources.py,sha256=4qVg5txsb10EHhvqXXeM6gJ2jx9LbroEnPydDv1uXs0,6176
132
- ominfra-0.0.0.dev173.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
133
- ominfra-0.0.0.dev173.dist-info/METADATA,sha256=PrY1ZdAiY9vgxekGjoC-9qePEbcgonN98lywYDWXCes,731
134
- ominfra-0.0.0.dev173.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
135
- ominfra-0.0.0.dev173.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
136
- ominfra-0.0.0.dev173.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
137
- ominfra-0.0.0.dev173.dist-info/RECORD,,
132
+ ominfra-0.0.0.dev174.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
133
+ ominfra-0.0.0.dev174.dist-info/METADATA,sha256=qeVp2nf876Zeu0NurT7Qldb4EuRYsIuTY9jAFc51DXo,731
134
+ ominfra-0.0.0.dev174.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
135
+ ominfra-0.0.0.dev174.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
136
+ ominfra-0.0.0.dev174.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
137
+ ominfra-0.0.0.dev174.dist-info/RECORD,,