omdev 0.0.0.dev214__py3-none-any.whl → 0.0.0.dev215__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.
- omdev/scripts/pyproject.py +79 -12
- {omdev-0.0.0.dev214.dist-info → omdev-0.0.0.dev215.dist-info}/METADATA +2 -2
- {omdev-0.0.0.dev214.dist-info → omdev-0.0.0.dev215.dist-info}/RECORD +7 -7
- {omdev-0.0.0.dev214.dist-info → omdev-0.0.0.dev215.dist-info}/LICENSE +0 -0
- {omdev-0.0.0.dev214.dist-info → omdev-0.0.0.dev215.dist-info}/WHEEL +0 -0
- {omdev-0.0.0.dev214.dist-info → omdev-0.0.0.dev215.dist-info}/entry_points.txt +0 -0
- {omdev-0.0.0.dev214.dist-info → omdev-0.0.0.dev215.dist-info}/top_level.txt +0 -0
omdev/scripts/pyproject.py
CHANGED
@@ -4962,6 +4962,7 @@ inj = InjectionApi()
|
|
4962
4962
|
TODO:
|
4963
4963
|
- pickle stdlib objs? have to pin to 3.8 pickle protocol, will be cross-version
|
4964
4964
|
- literals
|
4965
|
+
- Options.sequence_cls = list, mapping_cls = dict, ... - def with_mutable_containers() -> Options
|
4965
4966
|
"""
|
4966
4967
|
|
4967
4968
|
|
@@ -5114,21 +5115,55 @@ class IterableObjMarshaler(ObjMarshaler):
|
|
5114
5115
|
@dc.dataclass(frozen=True)
|
5115
5116
|
class FieldsObjMarshaler(ObjMarshaler):
|
5116
5117
|
ty: type
|
5117
|
-
|
5118
|
+
|
5119
|
+
@dc.dataclass(frozen=True)
|
5120
|
+
class Field:
|
5121
|
+
att: str
|
5122
|
+
key: str
|
5123
|
+
m: ObjMarshaler
|
5124
|
+
|
5125
|
+
omit_if_none: bool = False
|
5126
|
+
|
5127
|
+
fs: ta.Sequence[Field]
|
5128
|
+
|
5118
5129
|
non_strict: bool = False
|
5119
5130
|
|
5131
|
+
#
|
5132
|
+
|
5133
|
+
_fs_by_att: ta.ClassVar[ta.Mapping[str, Field]]
|
5134
|
+
_fs_by_key: ta.ClassVar[ta.Mapping[str, Field]]
|
5135
|
+
|
5136
|
+
def __post_init__(self) -> None:
|
5137
|
+
fs_by_att: dict = {}
|
5138
|
+
fs_by_key: dict = {}
|
5139
|
+
for f in self.fs:
|
5140
|
+
check.not_in(check.non_empty_str(f.att), fs_by_att)
|
5141
|
+
check.not_in(check.non_empty_str(f.key), fs_by_key)
|
5142
|
+
fs_by_att[f.att] = f
|
5143
|
+
fs_by_key[f.key] = f
|
5144
|
+
self.__dict__['_fs_by_att'] = fs_by_att
|
5145
|
+
self.__dict__['_fs_by_key'] = fs_by_key
|
5146
|
+
|
5147
|
+
#
|
5148
|
+
|
5120
5149
|
def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
5121
|
-
|
5122
|
-
|
5123
|
-
|
5124
|
-
|
5150
|
+
d = {}
|
5151
|
+
for f in self.fs:
|
5152
|
+
mv = f.m.marshal(getattr(o, f.att), ctx)
|
5153
|
+
if mv is None and f.omit_if_none:
|
5154
|
+
continue
|
5155
|
+
d[f.key] = mv
|
5156
|
+
return d
|
5125
5157
|
|
5126
5158
|
def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
|
5127
|
-
|
5128
|
-
|
5129
|
-
|
5130
|
-
|
5131
|
-
|
5159
|
+
kw = {}
|
5160
|
+
for k, v in o.items():
|
5161
|
+
if (f := self._fs_by_key.get(k)) is None:
|
5162
|
+
if not (self.non_strict or ctx.options.non_strict_fields):
|
5163
|
+
raise KeyError(k)
|
5164
|
+
continue
|
5165
|
+
kw[f.att] = f.m.unmarshal(v, ctx)
|
5166
|
+
return self.ty(**kw)
|
5132
5167
|
|
5133
5168
|
|
5134
5169
|
@dc.dataclass(frozen=True)
|
@@ -5263,6 +5298,22 @@ def register_single_field_type_obj_marshaler(fld, ty=None):
|
|
5263
5298
|
##
|
5264
5299
|
|
5265
5300
|
|
5301
|
+
class ObjMarshalerFieldMetadata:
|
5302
|
+
def __new__(cls, *args, **kwargs): # noqa
|
5303
|
+
raise TypeError
|
5304
|
+
|
5305
|
+
|
5306
|
+
class OBJ_MARSHALER_FIELD_KEY(ObjMarshalerFieldMetadata): # noqa
|
5307
|
+
pass
|
5308
|
+
|
5309
|
+
|
5310
|
+
class OBJ_MARSHALER_OMIT_IF_NONE(ObjMarshalerFieldMetadata): # noqa
|
5311
|
+
pass
|
5312
|
+
|
5313
|
+
|
5314
|
+
##
|
5315
|
+
|
5316
|
+
|
5266
5317
|
class ObjMarshalerManager:
|
5267
5318
|
def __init__(
|
5268
5319
|
self,
|
@@ -5322,14 +5373,30 @@ class ObjMarshalerManager:
|
|
5322
5373
|
if dc.is_dataclass(ty):
|
5323
5374
|
return FieldsObjMarshaler(
|
5324
5375
|
ty,
|
5325
|
-
|
5376
|
+
[
|
5377
|
+
FieldsObjMarshaler.Field(
|
5378
|
+
att=f.name,
|
5379
|
+
key=check.non_empty_str(fk),
|
5380
|
+
m=rec(f.type),
|
5381
|
+
omit_if_none=check.isinstance(f.metadata.get(OBJ_MARSHALER_OMIT_IF_NONE, False), bool),
|
5382
|
+
)
|
5383
|
+
for f in dc.fields(ty)
|
5384
|
+
if (fk := f.metadata.get(OBJ_MARSHALER_FIELD_KEY, f.name)) is not None
|
5385
|
+
],
|
5326
5386
|
non_strict=non_strict_fields,
|
5327
5387
|
)
|
5328
5388
|
|
5329
5389
|
if issubclass(ty, tuple) and hasattr(ty, '_fields'):
|
5330
5390
|
return FieldsObjMarshaler(
|
5331
5391
|
ty,
|
5332
|
-
|
5392
|
+
[
|
5393
|
+
FieldsObjMarshaler.Field(
|
5394
|
+
att=p.name,
|
5395
|
+
key=p.name,
|
5396
|
+
m=rec(p.annotation),
|
5397
|
+
)
|
5398
|
+
for p in inspect.signature(ty).parameters.values()
|
5399
|
+
],
|
5333
5400
|
non_strict=non_strict_fields,
|
5334
5401
|
)
|
5335
5402
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: omdev
|
3
|
-
Version: 0.0.0.
|
3
|
+
Version: 0.0.0.dev215
|
4
4
|
Summary: omdev
|
5
5
|
Author: wrmsr
|
6
6
|
License: BSD-3-Clause
|
@@ -12,7 +12,7 @@ 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: omlish==0.0.0.
|
15
|
+
Requires-Dist: omlish==0.0.0.dev215
|
16
16
|
Provides-Extra: all
|
17
17
|
Requires-Dist: black~=24.10; extra == "all"
|
18
18
|
Requires-Dist: pycparser~=2.22; extra == "all"
|
@@ -179,7 +179,7 @@ omdev/scripts/execrss.py,sha256=mR0G0wERBYtQmVIn63lCIIFb5zkCM6X_XOENDFYDBKc,651
|
|
179
179
|
omdev/scripts/exectime.py,sha256=sFb376GflU6s9gNX-2-we8hgH6w5MuQNS9g6i4SqJIo,610
|
180
180
|
omdev/scripts/importtrace.py,sha256=oa7CtcWJVMNDbyIEiRHej6ICfABfErMeo4_haIqe18Q,14041
|
181
181
|
omdev/scripts/interp.py,sha256=7NrLbOkiDjBldnzpf-EpL8UTmU6U3lakvHqhSlY3X_U,141851
|
182
|
-
omdev/scripts/pyproject.py,sha256=
|
182
|
+
omdev/scripts/pyproject.py,sha256=HDors8tvpSgCUzESwQ2E-Gx5jLisaYoOApOTCgmQ5P0,245595
|
183
183
|
omdev/scripts/slowcat.py,sha256=lssv4yrgJHiWfOiHkUut2p8E8Tq32zB-ujXESQxFFHY,2728
|
184
184
|
omdev/scripts/tmpexec.py,sha256=WTYcf56Tj2qjYV14AWmV8SfT0u6Y8eIU6cKgQRvEK3c,1442
|
185
185
|
omdev/tokens/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -211,9 +211,9 @@ omdev/tools/json/rendering.py,sha256=tMcjOW5edfozcMSTxxvF7WVTsbYLoe9bCKFh50qyaGw
|
|
211
211
|
omdev/tools/pawk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
212
212
|
omdev/tools/pawk/__main__.py,sha256=VCqeRVnqT1RPEoIrqHFSu4PXVMg4YEgF4qCQm90-eRI,66
|
213
213
|
omdev/tools/pawk/pawk.py,sha256=zsEkfQX0jF5bn712uqPAyBSdJt2dno1LH2oeSMNfXQI,11424
|
214
|
-
omdev-0.0.0.
|
215
|
-
omdev-0.0.0.
|
216
|
-
omdev-0.0.0.
|
217
|
-
omdev-0.0.0.
|
218
|
-
omdev-0.0.0.
|
219
|
-
omdev-0.0.0.
|
214
|
+
omdev-0.0.0.dev215.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
215
|
+
omdev-0.0.0.dev215.dist-info/METADATA,sha256=oNR4sVjlhZ4v-B5bp8h4XPFlDnI8aniDWCUq9WLk-ZM,1638
|
216
|
+
omdev-0.0.0.dev215.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
217
|
+
omdev-0.0.0.dev215.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
|
218
|
+
omdev-0.0.0.dev215.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
|
219
|
+
omdev-0.0.0.dev215.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|