_ = (args, kwargs)
def __binary_operator(self, op, other):
- span = self.__class__.span
+ span = dict.fromkeys(self.__class__.span).keys()
lhs = _selectconcat(*(self.storage[bit] for bit in span))
if isinstance(other, Field):
def __len__(cls):
return len(cls.__members__)
- @property
- def span(cls):
- return cls.__members__
-
def remap(cls, scheme):
if isinstance(scheme, type) and issubclass(scheme, Mapping):
scheme = range(len(scheme))
return cls.__class__(cls.__name__, (cls,), {}, items=items)
+ @property
+ def span(cls):
+ return cls.__members__
+
+ def traverse(cls, path):
+ yield (path, cls.__members__)
+
class Field(Reference, metaclass=FieldMeta):
def __len__(self):
for field in cls.__members__:
yield from field.span
+ def traverse(cls, path=""):
+ for (idx, field) in cls:
+ yield from field.traverse(path=f"{path}[{idx}]")
+
class Array(Reference, metaclass=ArrayMeta):
def __init__(self, storage):
for field in cls.__members__.values():
yield from field.span
+ def traverse(cls, path=""):
+ for (name, field) in cls:
+ if name == "_":
+ yield from field.traverse(path=path)
+ elif path == "":
+ yield from field.traverse(path=name)
+ else:
+ yield from field.traverse(path=f"{path}.{name}")
+
class Mapping(Reference, metaclass=MappingMeta):
def __init__(self, storage, **kwargs):