graviti.portex.factory
#
Template factory releated classes.
Module Contents#
Classes#
The base class of the template factory. |
|
The factory for FrozenFields. |
|
The factory for FrozenFields which needs kwargs transformed. |
|
The factory for ConnectedFields. |
|
The template factory for portex type. |
|
The template factory for a constant. |
|
The template factory for a variable. |
|
The template factory for a list. |
|
The template factory for a dict. |
|
The template factory for a tuple of name and PortexType. |
|
The template factory for a |
Functions#
|
Check the object unpack grammar and returns the corresponding factory. |
|
Check the input and returns the corresponding type factory. |
|
Check whether the input string is variable and returns the corresponding factory. |
|
Check input type and returns the corresponding factory. |
Attributes#
- class graviti.portex.factory.FrozenFieldsFactory(decl, imports)[source]#
Bases:
Factory
The factory for FrozenFields.
- Parameters
decl (Iterable[Dict[str, Any]]) – The decalaration of frozen fields.
imports (graviti.portex.package.Imports) – The
Imports
instance to specify the import scope of the fields.
- class graviti.portex.factory.FrozenFieldsFactoryWrapper(factory, kwargs_transformer)[source]#
Bases:
Factory
The factory for FrozenFields which needs kwargs transformed.
- Parameters
factory (Union[FrozenFieldsFactory, FrozenFieldsFactoryWrapper]) – The factory of frozen fields.
kwargs_transformer (Callable[Ellipsis, Dict[str, Any]]) – The method to transform the kwargs to the kwargs of base type.
- class graviti.portex.factory.ConnectedFieldsFactory(decl, class_, imports, kwargs_transformer)[source]#
The factory for ConnectedFields.
- Parameters
decl (Dict[str, Any]) – A dict which indicates a portex type.
class – The base type.
imports (graviti.portex.package.Imports) – The
Imports
instance to specify the import scope of the template.kwargs_transformer (Callable[Ellipsis, Dict[str, Any]]) – The method to transform the kwargs to the kwargs of base type.
class_ (Type[graviti.portex.base.PortexRecordBase]) –
- class graviti.portex.factory.TypeFactory(decl, imports)[source]#
Bases:
Factory
The template factory for portex type.
- Parameters
decl (Dict[str, Any]) – A dict which indicates a portex type.
imports (graviti.portex.package.Imports) –
- class graviti.portex.factory.ConstantFactory(decl)[source]#
Bases:
Factory
,Generic
[_C
]The template factory for a constant.
- Parameters
decl (_C) – The constant to be created by the factory.
- class graviti.portex.factory.VariableFactory(decl, ptype=PTYPE.Any, is_unpack=False)[source]#
Bases:
Factory
The template factory for a variable.
- Parameters
decl (str) – The parameter name of the variable.
ptype (graviti.portex.ptype.PType) – The parameter type.
is_unpack (bool) –
- class graviti.portex.factory.ListFactory(decl, ptype=PTYPE.Any)[source]#
Bases:
Factory
The template factory for a list.
- Parameters
decl (List[Any]) – A list template.
ptype (graviti.portex.ptype.PType) – The parameter type of the list.
- class graviti.portex.factory.DictFactory(decl, ptype=PTYPE.Any)[source]#
Bases:
Factory
The template factory for a dict.
- Parameters
decl (Dict[str, Any]) – A dict template.
ptype (graviti.portex.ptype.PType) – The parameter type of the dict.
- class graviti.portex.factory.FieldFactory(decl, imports)[source]#
Bases:
Factory
The template factory for a tuple of name and PortexType.
- Parameters
decl (Dict[str, Any]) – A dict which indicates a tuple of name and PortexType.
imports (graviti.portex.package.Imports) –
- class graviti.portex.factory.FieldsFactory(decl, imports)[source]#
Bases:
Factory
The template factory for a
Fields
.- Parameters
decl (List[Union[Dict[str, Any], str]]) – A list which indicates a
Fields
.imports (graviti.portex.package.Imports) –
- graviti.portex.factory.mapping_unpack_factory_creator(decl, ptype)[source]#
Check the object unpack grammar and returns the corresponding factory.
- Parameters
decl (str) – The parameter decalaration.
ptype (graviti.portex.ptype.PType) – The parameter type of the input.
- Raises
ValueError – When the object unpack grammar is incorrect.
- Returns
A
VariableFactory
instance according to the input.- Return type
- graviti.portex.factory.type_factory_creator(decl, imports)[source]#
Check the input and returns the corresponding type factory.
- Parameters
decl (Dict[str, Any]) – A dict which indicates a portex type or has object unpack grammar.
imports (graviti.portex.package.Imports) – The
Imports
instance to specify the import scope of the template.
- Raises
ValueError – When setting the type name as a parameter.
- Returns
A
TypeFactory
or aVariableFactory
instance.- Return type
Union[TypeFactory, VariableFactory]
- graviti.portex.factory.string_factory_creator(decl, ptype=PTYPE.Any)[source]#
Check whether the input string is variable and returns the corresponding factory.
- Parameters
decl (str) – A string which indicates a constant or a variable.
ptype (graviti.portex.ptype.PType) – The parameter type of the string.
- Returns
A
VariableFactory
or aConstantFactory
instance according to the input.- Return type
Union[VariableFactory, ConstantFactory[str]]
- graviti.portex.factory.factory_creator(decl, imports, ptype=PTYPE.Any)[source]#
Check input type and returns the corresponding factory.
- Parameters
decl (Any) – A template which indicates any Portex object.
imports (Optional[graviti.portex.package.Imports]) – The
Imports
instance to specify the import scope of the template.ptype (graviti.portex.ptype.PType) – The parameter type of the input.
- Returns
A
Factory
instance according the input.- Return type