ominfra 0.0.0.dev173__py3-none-any.whl → 0.0.0.dev175__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- ominfra/manage/deploy/conf.py +12 -6
- ominfra/manage/deploy/paths/paths.py +2 -2
- ominfra/manage/deploy/specs.py +3 -9
- ominfra/scripts/journald2aws.py +46 -0
- ominfra/scripts/manage.py +62 -15
- ominfra/scripts/supervisor.py +46 -0
- {ominfra-0.0.0.dev173.dist-info → ominfra-0.0.0.dev175.dist-info}/METADATA +3 -3
- {ominfra-0.0.0.dev173.dist-info → ominfra-0.0.0.dev175.dist-info}/RECORD +12 -12
- {ominfra-0.0.0.dev173.dist-info → ominfra-0.0.0.dev175.dist-info}/LICENSE +0 -0
- {ominfra-0.0.0.dev173.dist-info → ominfra-0.0.0.dev175.dist-info}/WHEEL +0 -0
- {ominfra-0.0.0.dev173.dist-info → ominfra-0.0.0.dev175.dist-info}/entry_points.txt +0 -0
- {ominfra-0.0.0.dev173.dist-info → ominfra-0.0.0.dev175.dist-info}/top_level.txt +0 -0
ominfra/manage/deploy/conf.py
CHANGED
@@ -24,13 +24,12 @@ from omlish.os.paths import is_path_in_dir
|
|
24
24
|
from omlish.os.paths import relative_symlink
|
25
25
|
|
26
26
|
from .paths.paths import DeployPath
|
27
|
-
from .specs import AllActiveDeployAppConfLink
|
28
|
-
from .specs import CurrentOnlyDeployAppConfLink
|
29
27
|
from .specs import DeployAppConfFile
|
30
28
|
from .specs import DeployAppConfLink
|
31
29
|
from .specs import DeployAppConfSpec
|
32
30
|
from .tags import DEPLOY_TAG_SEPARATOR
|
33
31
|
from .tags import DeployApp
|
32
|
+
from .tags import DeployConf
|
34
33
|
from .tags import DeployTagMap
|
35
34
|
from .types import DeployHome
|
36
35
|
|
@@ -63,6 +62,7 @@ class DeployConfManager:
|
|
63
62
|
#
|
64
63
|
|
65
64
|
class _ComputedConfLink(ta.NamedTuple):
|
65
|
+
conf: DeployConf
|
66
66
|
is_dir: bool
|
67
67
|
link_src: str
|
68
68
|
link_dst: str
|
@@ -70,8 +70,9 @@ class DeployConfManager:
|
|
70
70
|
_UNIQUE_LINK_NAME_STR = '@app--@time--@app-key'
|
71
71
|
_UNIQUE_LINK_NAME = DeployPath.parse(_UNIQUE_LINK_NAME_STR)
|
72
72
|
|
73
|
+
@classmethod
|
73
74
|
def _compute_app_conf_link_dst(
|
74
|
-
|
75
|
+
cls,
|
75
76
|
link: DeployAppConfLink,
|
76
77
|
tags: DeployTagMap,
|
77
78
|
app_conf_dir: str,
|
@@ -85,6 +86,7 @@ class DeployConfManager:
|
|
85
86
|
if (is_dir := link.src.endswith('/')):
|
86
87
|
# @conf/ - links a directory in root of app conf dir to conf/@conf/@dst/
|
87
88
|
check.arg(link.src.count('/') == 1)
|
89
|
+
conf = DeployConf(link.src.split('/')[0])
|
88
90
|
link_dst_pfx = link.src
|
89
91
|
link_dst_sfx = ''
|
90
92
|
|
@@ -92,6 +94,7 @@ class DeployConfManager:
|
|
92
94
|
# @conf/file - links a single file in a single subdir to conf/@conf/@dst--file
|
93
95
|
d, f = os.path.split(link.src)
|
94
96
|
# TODO: check filename :|
|
97
|
+
conf = DeployConf(d)
|
95
98
|
link_dst_pfx = d + '/'
|
96
99
|
link_dst_sfx = DEPLOY_TAG_SEPARATOR + f
|
97
100
|
|
@@ -99,18 +102,20 @@ class DeployConfManager:
|
|
99
102
|
# @conf(.ext)* - links a single file in root of app conf dir to conf/@conf/@dst(.ext)*
|
100
103
|
if '.' in link.src:
|
101
104
|
l, _, r = link.src.partition('.')
|
105
|
+
conf = DeployConf(l)
|
102
106
|
link_dst_pfx = l + '/'
|
103
107
|
link_dst_sfx = '.' + r
|
104
108
|
else:
|
109
|
+
conf = DeployConf(link.src)
|
105
110
|
link_dst_pfx = link.src + '/'
|
106
111
|
link_dst_sfx = ''
|
107
112
|
|
108
113
|
#
|
109
114
|
|
110
|
-
if
|
115
|
+
if link.kind == 'current_only':
|
111
116
|
link_dst_mid = str(tags[DeployApp].s)
|
112
|
-
elif
|
113
|
-
link_dst_mid =
|
117
|
+
elif link.kind == 'all_active':
|
118
|
+
link_dst_mid = cls._UNIQUE_LINK_NAME.render(tags)
|
114
119
|
else:
|
115
120
|
raise TypeError(link)
|
116
121
|
|
@@ -124,6 +129,7 @@ class DeployConfManager:
|
|
124
129
|
link_dst = os.path.join(conf_link_dir, link_dst_name)
|
125
130
|
|
126
131
|
return DeployConfManager._ComputedConfLink(
|
132
|
+
conf=conf,
|
127
133
|
is_dir=is_dir,
|
128
134
|
link_src=link_src,
|
129
135
|
link_dst=link_dst,
|
@@ -170,7 +170,7 @@ class FileDeployPathPart(DeployPathPart):
|
|
170
170
|
return 'file'
|
171
171
|
|
172
172
|
|
173
|
-
|
173
|
+
##
|
174
174
|
|
175
175
|
|
176
176
|
@dc.dataclass(frozen=True)
|
@@ -197,7 +197,7 @@ class DeployPath:
|
|
197
197
|
return pd
|
198
198
|
|
199
199
|
@property
|
200
|
-
def kind(self) ->
|
200
|
+
def kind(self) -> DeployPathKind:
|
201
201
|
return self.parts[-1].kind
|
202
202
|
|
203
203
|
def render(self, tags: ta.Optional[DeployTagMap] = None) -> str:
|
ominfra/manage/deploy/specs.py
CHANGED
@@ -95,7 +95,7 @@ class DeployAppConfFile:
|
|
95
95
|
|
96
96
|
|
97
97
|
@dc.dataclass(frozen=True)
|
98
|
-
class DeployAppConfLink
|
98
|
+
class DeployAppConfLink: # noqa
|
99
99
|
"""
|
100
100
|
May be either:
|
101
101
|
- @conf(.ext)* - links a single file in root of app conf dir to conf/@conf/@dst(.ext)*
|
@@ -105,20 +105,14 @@ class DeployAppConfLink(abc.ABC): # noqa
|
|
105
105
|
|
106
106
|
src: str
|
107
107
|
|
108
|
+
kind: ta.Literal['current_only', 'all_active'] = 'current_only'
|
109
|
+
|
108
110
|
def __post_init__(self) -> None:
|
109
111
|
check_valid_deploy_spec_path(self.src)
|
110
112
|
if '/' in self.src:
|
111
113
|
check.equal(self.src.count('/'), 1)
|
112
114
|
|
113
115
|
|
114
|
-
class CurrentOnlyDeployAppConfLink(DeployAppConfLink):
|
115
|
-
pass
|
116
|
-
|
117
|
-
|
118
|
-
class AllActiveDeployAppConfLink(DeployAppConfLink):
|
119
|
-
pass
|
120
|
-
|
121
|
-
|
122
116
|
#
|
123
117
|
|
124
118
|
|
ominfra/scripts/journald2aws.py
CHANGED
@@ -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)]
|
@@ -7038,7 +7084,7 @@ class FileDeployPathPart(DeployPathPart):
|
|
7038
7084
|
return 'file'
|
7039
7085
|
|
7040
7086
|
|
7041
|
-
|
7087
|
+
##
|
7042
7088
|
|
7043
7089
|
|
7044
7090
|
@dc.dataclass(frozen=True)
|
@@ -7065,7 +7111,7 @@ class DeployPath:
|
|
7065
7111
|
return pd
|
7066
7112
|
|
7067
7113
|
@property
|
7068
|
-
def kind(self) ->
|
7114
|
+
def kind(self) -> DeployPathKind:
|
7069
7115
|
return self.parts[-1].kind
|
7070
7116
|
|
7071
7117
|
def render(self, tags: ta.Optional[DeployTagMap] = None) -> str:
|
@@ -7160,7 +7206,7 @@ class DeployAppConfFile:
|
|
7160
7206
|
|
7161
7207
|
|
7162
7208
|
@dc.dataclass(frozen=True)
|
7163
|
-
class DeployAppConfLink
|
7209
|
+
class DeployAppConfLink: # noqa
|
7164
7210
|
"""
|
7165
7211
|
May be either:
|
7166
7212
|
- @conf(.ext)* - links a single file in root of app conf dir to conf/@conf/@dst(.ext)*
|
@@ -7170,20 +7216,14 @@ class DeployAppConfLink(abc.ABC): # noqa
|
|
7170
7216
|
|
7171
7217
|
src: str
|
7172
7218
|
|
7219
|
+
kind: ta.Literal['current_only', 'all_active'] = 'current_only'
|
7220
|
+
|
7173
7221
|
def __post_init__(self) -> None:
|
7174
7222
|
check_valid_deploy_spec_path(self.src)
|
7175
7223
|
if '/' in self.src:
|
7176
7224
|
check.equal(self.src.count('/'), 1)
|
7177
7225
|
|
7178
7226
|
|
7179
|
-
class CurrentOnlyDeployAppConfLink(DeployAppConfLink):
|
7180
|
-
pass
|
7181
|
-
|
7182
|
-
|
7183
|
-
class AllActiveDeployAppConfLink(DeployAppConfLink):
|
7184
|
-
pass
|
7185
|
-
|
7186
|
-
|
7187
7227
|
#
|
7188
7228
|
|
7189
7229
|
|
@@ -7871,6 +7911,7 @@ class DeployConfManager:
|
|
7871
7911
|
#
|
7872
7912
|
|
7873
7913
|
class _ComputedConfLink(ta.NamedTuple):
|
7914
|
+
conf: DeployConf
|
7874
7915
|
is_dir: bool
|
7875
7916
|
link_src: str
|
7876
7917
|
link_dst: str
|
@@ -7878,8 +7919,9 @@ class DeployConfManager:
|
|
7878
7919
|
_UNIQUE_LINK_NAME_STR = '@app--@time--@app-key'
|
7879
7920
|
_UNIQUE_LINK_NAME = DeployPath.parse(_UNIQUE_LINK_NAME_STR)
|
7880
7921
|
|
7922
|
+
@classmethod
|
7881
7923
|
def _compute_app_conf_link_dst(
|
7882
|
-
|
7924
|
+
cls,
|
7883
7925
|
link: DeployAppConfLink,
|
7884
7926
|
tags: DeployTagMap,
|
7885
7927
|
app_conf_dir: str,
|
@@ -7893,6 +7935,7 @@ class DeployConfManager:
|
|
7893
7935
|
if (is_dir := link.src.endswith('/')):
|
7894
7936
|
# @conf/ - links a directory in root of app conf dir to conf/@conf/@dst/
|
7895
7937
|
check.arg(link.src.count('/') == 1)
|
7938
|
+
conf = DeployConf(link.src.split('/')[0])
|
7896
7939
|
link_dst_pfx = link.src
|
7897
7940
|
link_dst_sfx = ''
|
7898
7941
|
|
@@ -7900,6 +7943,7 @@ class DeployConfManager:
|
|
7900
7943
|
# @conf/file - links a single file in a single subdir to conf/@conf/@dst--file
|
7901
7944
|
d, f = os.path.split(link.src)
|
7902
7945
|
# TODO: check filename :|
|
7946
|
+
conf = DeployConf(d)
|
7903
7947
|
link_dst_pfx = d + '/'
|
7904
7948
|
link_dst_sfx = DEPLOY_TAG_SEPARATOR + f
|
7905
7949
|
|
@@ -7907,18 +7951,20 @@ class DeployConfManager:
|
|
7907
7951
|
# @conf(.ext)* - links a single file in root of app conf dir to conf/@conf/@dst(.ext)*
|
7908
7952
|
if '.' in link.src:
|
7909
7953
|
l, _, r = link.src.partition('.')
|
7954
|
+
conf = DeployConf(l)
|
7910
7955
|
link_dst_pfx = l + '/'
|
7911
7956
|
link_dst_sfx = '.' + r
|
7912
7957
|
else:
|
7958
|
+
conf = DeployConf(link.src)
|
7913
7959
|
link_dst_pfx = link.src + '/'
|
7914
7960
|
link_dst_sfx = ''
|
7915
7961
|
|
7916
7962
|
#
|
7917
7963
|
|
7918
|
-
if
|
7964
|
+
if link.kind == 'current_only':
|
7919
7965
|
link_dst_mid = str(tags[DeployApp].s)
|
7920
|
-
elif
|
7921
|
-
link_dst_mid =
|
7966
|
+
elif link.kind == 'all_active':
|
7967
|
+
link_dst_mid = cls._UNIQUE_LINK_NAME.render(tags)
|
7922
7968
|
else:
|
7923
7969
|
raise TypeError(link)
|
7924
7970
|
|
@@ -7932,6 +7978,7 @@ class DeployConfManager:
|
|
7932
7978
|
link_dst = os.path.join(conf_link_dir, link_dst_name)
|
7933
7979
|
|
7934
7980
|
return DeployConfManager._ComputedConfLink(
|
7981
|
+
conf=conf,
|
7935
7982
|
is_dir=is_dir,
|
7936
7983
|
link_src=link_src,
|
7937
7984
|
link_dst=link_dst,
|
ominfra/scripts/supervisor.py
CHANGED
@@ -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.
|
3
|
+
Version: 0.0.0.dev175
|
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.
|
16
|
-
Requires-Dist: omlish==0.0.0.
|
15
|
+
Requires-Dist: omdev==0.0.0.dev175
|
16
|
+
Requires-Dist: omlish==0.0.0.dev175
|
17
17
|
Provides-Extra: all
|
18
18
|
Requires-Dist: paramiko~=3.5; extra == "all"
|
19
19
|
Requires-Dist: asyncssh~=2.18; extra == "all"
|
@@ -46,13 +46,13 @@ ominfra/manage/commands/types.py,sha256=XFZPeqeIBAaIIQF3pdPbGxLlb-LCrz6WtlDWO2q_
|
|
46
46
|
ominfra/manage/deploy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
47
47
|
ominfra/manage/deploy/apps.py,sha256=4qcUi7Zxd2Sgfb8ZQSbjiMv1ppkHpJ37zJJMeDs6_xo,4738
|
48
48
|
ominfra/manage/deploy/commands.py,sha256=fKFKhFwqIqC_PsgA-W66qIJ5S32xRgBBaRt3lbPX5Zg,763
|
49
|
-
ominfra/manage/deploy/conf.py,sha256=
|
49
|
+
ominfra/manage/deploy/conf.py,sha256=cGu9q-mtbBsBXydTGrNE11NGyYdxbn7aPiGx28rxhsg,5639
|
50
50
|
ominfra/manage/deploy/config.py,sha256=aR6ubMEWqkTI55XtcG1Cczn6YhCVN6eSL8DT5EHQJN0,166
|
51
51
|
ominfra/manage/deploy/deploy.py,sha256=zEcuwH7Sj3Z5Wb5U9RDqEG8CHaOZVhGpPBBTGGER2j4,1672
|
52
52
|
ominfra/manage/deploy/git.py,sha256=cfTCx1qD-FQPFkbYW28tkU8nVxQbnfnWxpuJuGQHtBw,3753
|
53
53
|
ominfra/manage/deploy/inject.py,sha256=kzGl2N2jhijUw4-PYUK1LNG8_MJD7BMgCbi6nDViMWg,1965
|
54
54
|
ominfra/manage/deploy/interp.py,sha256=OKkenH8YKEW_mEDR6X7_ZLxK9a1Ox6KHSwFPTHT6OzA,1029
|
55
|
-
ominfra/manage/deploy/specs.py,sha256=
|
55
|
+
ominfra/manage/deploy/specs.py,sha256=XIEOdLwULFprLajjzX6Qf_T3wVvEWeC4tIZgYbycCHI,3656
|
56
56
|
ominfra/manage/deploy/tags.py,sha256=f2gTcV9aOGv5A6-6ZESHzeQ47TcLTkaEXe60_JyvqQo,4977
|
57
57
|
ominfra/manage/deploy/tmp.py,sha256=dFJuqGfSf5otCxSaCI01a5UOSaArMlU4MzzYcyr74-s,1237
|
58
58
|
ominfra/manage/deploy/types.py,sha256=ZcIoheZ3zW7n0IZiqTRW_Uo3JyWWeWg5nyKGryvGc2I,112
|
@@ -61,7 +61,7 @@ ominfra/manage/deploy/paths/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
|
|
61
61
|
ominfra/manage/deploy/paths/inject.py,sha256=X81C-Qhef1LQ7tILWvkomBwFTvgooLVmWRnKL7TeVoI,596
|
62
62
|
ominfra/manage/deploy/paths/manager.py,sha256=gxr_CsjLmjxXx8w3J8ookJk9OGltCpyBFYBnxXaw5lg,1050
|
63
63
|
ominfra/manage/deploy/paths/owners.py,sha256=GmLy0E70C8CF3eYIdkAhBtYaZXW4QWmSzvgts5l1i_4,1379
|
64
|
-
ominfra/manage/deploy/paths/paths.py,sha256=
|
64
|
+
ominfra/manage/deploy/paths/paths.py,sha256=i7g8YdYOh4M_jgJXtafTbFkRhlu469cfGxAJAuB3fVY,5531
|
65
65
|
ominfra/manage/deploy/paths/types.py,sha256=TGgtSASmdyuZ2maZnvahfA0QxPLWlHBtpDeIEoEDGxk,112
|
66
66
|
ominfra/manage/remote/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
67
67
|
ominfra/manage/remote/_main.py,sha256=p5KoiS2WMw6QAqlDl_Zun-JybmCsy8awIfpBMLBjGMY,4356
|
@@ -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=
|
89
|
-
ominfra/scripts/manage.py,sha256=
|
90
|
-
ominfra/scripts/supervisor.py,sha256=
|
88
|
+
ominfra/scripts/journald2aws.py,sha256=fbs8jZCsnwi5vF8Bg892wu3rscHCHeLQlvsDs6oAZBs,156681
|
89
|
+
ominfra/scripts/manage.py,sha256=K9Z5QjGH3maQYwRnW3UbvL7dkdAk4-mLwvgWVC8TLSg,316780
|
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.
|
133
|
-
ominfra-0.0.0.
|
134
|
-
ominfra-0.0.0.
|
135
|
-
ominfra-0.0.0.
|
136
|
-
ominfra-0.0.0.
|
137
|
-
ominfra-0.0.0.
|
132
|
+
ominfra-0.0.0.dev175.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
133
|
+
ominfra-0.0.0.dev175.dist-info/METADATA,sha256=mSx5m3-8qdibsCJFkrdMM2Z7H2DonPWOBSnJFlETz2M,731
|
134
|
+
ominfra-0.0.0.dev175.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
135
|
+
ominfra-0.0.0.dev175.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
|
136
|
+
ominfra-0.0.0.dev175.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
|
137
|
+
ominfra-0.0.0.dev175.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|