![]() |
Qucs-S S-parameter Viewer & RF Synthesis Tools
|

Public Member Functions | |
| None | __init__ (self, Callable[[], Any] dict_factory=dict, UnstructureStrategy unstruct_strat=UnstructureStrategy.AS_DICT, bool prefer_attrib_converters=False, bool detailed_validation=True, HookFactory[UnstructureHook] unstructure_fallback_factory=lambda _:identity, HookFactory[StructureHook] structure_fallback_factory=lambda _:raise_error) |
| Any | unstructure (self, Any obj, Any unstructure_as=None) |
| UnstructureStrategy | unstruct_strat (self) |
| UnstructureHookT | register_unstructure_hook (self, UnstructureHookT cls) |
| None | register_unstructure_hook (self, Any cls, UnstructureHook func) |
| Callable[[UnstructureHook]]|None | register_unstructure_hook (self, Any cls=None, UnstructureHook|None func=None) |
| None | register_unstructure_hook_func (self, Predicate check_func, UnstructureHook func) |
| Callable[[AnyUnstructureHookFactoryBase], AnyUnstructureHookFactoryBase] | register_unstructure_hook_factory (self, Predicate predicate) |
| UnstructureHookFactory | register_unstructure_hook_factory (self, Predicate predicate, UnstructureHookFactory factory) |
| ExtendedUnstructureHookFactory[BaseConverter] | register_unstructure_hook_factory (self, Predicate predicate, ExtendedUnstructureHookFactory[BaseConverter] factory) |
| register_unstructure_hook_factory (self, predicate, factory=None) | |
| UnstructureHook | get_unstructure_hook (self, Any type, bool cache_result=True) |
| StructureHookT | register_structure_hook (self, StructureHookT cl) |
| None | register_structure_hook (self, Any cl, StructureHook func) |
| None | register_structure_hook (self, Any cl, StructureHook|None func=None) |
| None | register_structure_hook_func (self, Predicate check_func, StructureHook func) |
| Callable[[AnyStructureHookFactoryBase], AnyStructureHookFactoryBase] | register_structure_hook_factory (self, Predicate predicate) |
| StructureHookFactory | register_structure_hook_factory (self, Predicate predicate, StructureHookFactory factory) |
| ExtendedStructureHookFactory[BaseConverter] | register_structure_hook_factory (self, Predicate predicate, ExtendedStructureHookFactory[BaseConverter] factory) |
| register_structure_hook_factory (self, predicate, factory=None) | |
| T | structure (self, UnstructuredValue obj, type[T] cl) |
| StructureHook | get_structure_hook (self, Any type, bool cache_result=True) |
| dict[str, Any] | unstructure_attrs_asdict (self, Any obj) |
| tuple[Any,...] | unstructure_attrs_astuple (self, Any obj) |
| T | structure_attrs_fromtuple (self, tuple[Any,...] obj, type[T] cl) |
| T | structure_attrs_fromdict (self, Mapping[str, Any] obj, type[T] cl) |
| BaseConverter | __deepcopy__ (self, _) |
| BaseConverter | copy (self, Callable[[], Any]|None dict_factory=None, UnstructureStrategy|None unstruct_strat=None, bool|None prefer_attrib_converters=None, bool|None detailed_validation=None) |
Public Attributes | |
| detailed_validation | |
| unstructure | |
Protected Member Functions | |
| Any | _unstructure_enum (self, Enum obj) |
| Sequence[T] | _unstructure_seq (self, Sequence[T] seq) |
| Mapping[T, V] | _unstructure_mapping (self, Mapping[T, V] mapping) |
| Any | _unstructure_union (self, Any obj) |
| DictStructureFn[T] | _gen_structure_generic (self, type[T] cl) |
| Callable[[Any, type[T]], type[T]|None] | _gen_attrs_union_structure (self, Any cl, bool use_literals=True) |
| StructuredValue | _structure_newtype (self, UnstructuredValue val, type) |
| StructureHook | _find_type_alias_structure_hook (self, Any type) |
| _structure_final_factory (self, type) | |
| Any | _structure_attribute (self, Attribute|Field a, Any value) |
| deque[T] | _structure_deque (self, Iterable[T] obj, Any cl) |
| Set[T] | _structure_set (self, Iterable[T] obj, Any cl, type structure_to=set) |
| FrozenSetSubscriptable[T] | _structure_frozenset (self, Iterable[T] obj, Any cl) |
| dict[T, V] | _structure_dict (self, Mapping[T, V] obj, Any cl) |
| _structure_optional (self, obj, union) | |
| T | _structure_tuple (self, Any obj, type[T] tup) |
| Callable[[Any], type] | _get_dis_func (self, Any union, bool use_literals=True, dict[str, AttributeOverride]|None overrides=None) |
Static Protected Member Functions | |
| Any | _structure_call (Any obj, type[T] cl) |
| _structure_simple_literal (val, type) | |
| _structure_enum_literal (val, type) | |
Converts between structured and unstructured data.
| None cattrs.converters.BaseConverter.__init__ | ( | self, | |
| Callable[[], Any] | dict_factory = dict, |
||
| UnstructureStrategy | unstruct_strat = UnstructureStrategy.AS_DICT, |
||
| bool | prefer_attrib_converters = False, |
||
| bool | detailed_validation = True, |
||
| HookFactory[UnstructureHook] | unstructure_fallback_factory = lambda _: identity, |
||
| HookFactory[StructureHook] | structure_fallback_factory = lambda _: raise_error |
||
| ) |
:param detailed_validation: Whether to use a slightly slower mode for detailed
validation errors.
:param unstructure_fallback_factory: A hook factory to be called when no
registered unstructuring hooks match.
:param structure_fallback_factory: A hook factory to be called when no
registered structuring hooks match.
.. versionadded:: 23.2.0 *unstructure_fallback_factory*
.. versionadded:: 23.2.0 *structure_fallback_factory*
Reimplemented in cattrs.converters.Converter.
|
protected |
Generate a structuring function for a union of attrs classes (and maybe None). :param use_literals: Whether to consider literal fields.
|
protected |
Create and return a hook for structuring generics.
|
protected |
Fetch or try creating a disambiguation function for a union.
|
protected |
Handle an individual attrs attribute.
|
staticprotected |
Just call ``cl`` with the given ``obj``. This is just an optimization on the ``_structure_default`` case, when we know we can skip the ``if`` s. Use for ``str``, ``bytes``, ``enum``, etc.
|
protected |
Convert an iterable to a potentially generic deque.
|
protected |
Convert a mapping into a potentially generic dict.
|
protected |
Convert an iterable into a potentially generic frozenset.
|
protected |
Convert an iterable into a potentially generic set.
|
protected |
Deal with structuring into a tuple.
|
protected |
Convert an enum to its value.
|
protected |
Convert a mapping of attr classes to primitive equivalents.
|
protected |
Convert a sequence to primitive equivalents.
|
protected |
Unstructure an object as a union. By default, just unstructures the instance.
| BaseConverter cattrs.converters.BaseConverter.copy | ( | self, | |
| Callable[[], Any] | None | dict_factory = None, |
||
| UnstructureStrategy | None | unstruct_strat = None, |
||
| bool | None | prefer_attrib_converters = None, |
||
| bool | None | detailed_validation = None |
||
| ) |
Create a copy of the converter, keeping all existing custom hooks.
:param detailed_validation: Whether to use a slightly slower mode for detailed
validation errors.
Reimplemented in cattrs.converters.Converter.
| StructureHook cattrs.converters.BaseConverter.get_structure_hook | ( | self, | |
| Any | type, | ||
| bool | cache_result = True |
||
| ) |
Get the structure hook for the given type. This hook can be manually called, or composed with other functions and re-registered. If no hook is registered, the converter structure fallback factory will be used to produce one. :param cache: Whether to cache the returned hook. .. versionadded:: 24.1.0
| UnstructureHook cattrs.converters.BaseConverter.get_unstructure_hook | ( | self, | |
| Any | type, | ||
| bool | cache_result = True |
||
| ) |
Get the unstructure hook for the given type. This hook can be manually called, or composed with other functions and re-registered. If no hook is registered, the converter unstructure fallback factory will be used to produce one. :param cache: Whether to cache the returned hook. .. versionadded:: 24.1.0
| None cattrs.converters.BaseConverter.register_structure_hook | ( | self, | |
| Any | cl, | ||
| StructureHook | None | func = None |
||
| ) |
Register a primitive-to-class converter function for a type.
The converter function should take two arguments:
* a Python object to be converted,
* the type to convert to
and return the instance of the class. The type may seem redundant, but
is sometimes needed (for example, when dealing with generic classes).
This method may be used as a decorator. In this case, the decorated
hook must have a return type annotation, and this annotation will be used
as the type for the hook.
.. versionchanged:: 24.1.0
This method may now be used as a decorator.
| cattrs.converters.BaseConverter.register_structure_hook_factory | ( | self, | |
| predicate, | |||
factory = None |
|||
| ) |
Register a hook factory for a given predicate.
The hook factory may expose an additional required parameter. In this case,
the current converter will be provided to the hook factory as that
parameter.
May also be used as a decorator.
:param predicate: A function that, given a type, returns whether the factory
can produce a hook for that type.
:param factory: A callable that, given a type, produces a structuring
hook for that type. This structuring hook will be cached.
.. versionchanged:: 24.1.0
This method may now be used as a decorator.
The factory may also receive the converter as a second, required argument.
| None cattrs.converters.BaseConverter.register_structure_hook_func | ( | self, | |
| Predicate | check_func, | ||
| StructureHook | func | ||
| ) |
Register a class-to-primitive converter function for a class, using a function to check if it's a match.
| Callable[[UnstructureHook]] | None cattrs.converters.BaseConverter.register_unstructure_hook | ( | self, | |
| Any | cls = None, |
||
| UnstructureHook | None | func = None |
||
| ) |
Register a class-to-primitive converter function for a class.
The converter function should take an instance of the class and return
its Python equivalent.
May also be used as a decorator. When used as a decorator, the first
argument annotation from the decorated function will be used as the
type to register the hook for.
.. versionchanged:: 24.1.0
This method may now be used as a decorator.
| cattrs.converters.BaseConverter.register_unstructure_hook_factory | ( | self, | |
| predicate, | |||
factory = None |
|||
| ) |
Register a hook factory for a given predicate.
The hook factory may expose an additional required parameter. In this case,
the current converter will be provided to the hook factory as that
parameter.
May also be used as a decorator.
:param predicate: A function that, given a type, returns whether the factory
can produce a hook for that type.
:param factory: A callable that, given a type, produces an unstructuring
hook for that type. This unstructuring hook will be cached.
.. versionchanged:: 24.1.0
This method may now be used as a decorator.
The factory may also receive the converter as a second, required argument.
| None cattrs.converters.BaseConverter.register_unstructure_hook_func | ( | self, | |
| Predicate | check_func, | ||
| UnstructureHook | func | ||
| ) |
Register a class-to-primitive converter function for a class, using a function to check if it's a match.
| T cattrs.converters.BaseConverter.structure | ( | self, | |
| UnstructuredValue | obj, | ||
| type[T] | cl | ||
| ) |
Convert unstructured Python data structures to structured data.
| T cattrs.converters.BaseConverter.structure_attrs_fromdict | ( | self, | |
| Mapping[str, Any] | obj, | ||
| type[T] | cl | ||
| ) |
Instantiate an attrs class from a mapping (dict).
| T cattrs.converters.BaseConverter.structure_attrs_fromtuple | ( | self, | |
| tuple[Any, ...] | obj, | ||
| type[T] | cl | ||
| ) |
Load an attrs class from a sequence (tuple).
| UnstructureStrategy cattrs.converters.BaseConverter.unstruct_strat | ( | self | ) |
The default way of unstructuring ``attrs`` classes.
| dict[str, Any] cattrs.converters.BaseConverter.unstructure_attrs_asdict | ( | self, | |
| Any | obj | ||
| ) |
Our version of `attrs.asdict`, so we can call back to us.
| tuple[Any, ...] cattrs.converters.BaseConverter.unstructure_attrs_astuple | ( | self, | |
| Any | obj | ||
| ) |
Our version of `attrs.astuple`, so we can call back to us.