graviti.portex.ptype
#
Parameter type releated classes.
Module Contents#
Classes#
The base class of parameter type. |
|
Unconstrained parameter type. |
|
Parameter type for JSON Boolean. |
|
Parameter type for JSON Array. |
|
Parameter type for JSON object. |
|
Parameter type for JSON number. |
|
Parameter type for JSON integer. |
|
Parameter type for JSON string. |
|
Parameter type for Portex enum values. |
|
Parameter type for Portex record field. |
|
Parameter type for Portex record fields. |
|
Parameter type for Portex type. |
Attributes#
- class graviti.portex.ptype.ParameterType[source]#
The base class of parameter type.
- static load(content, _=None)[source]#
Create an instance of the parameter type from the python content.
- Parameters
content (Any) – A python presentation of the parameter type.
_ (Optional[graviti.portex.package.Imports]) – The imports of the parameter type.
- Returns
An instance of the parameter type.
- Return type
- class graviti.portex.ptype.Any[source]#
Bases:
ParameterType
Unconstrained parameter type.
- class graviti.portex.ptype.Enum[source]#
Bases:
ParameterType
Parameter type for Portex enum values.
- static check(arg)[source]#
Check and transfer the parameter type.
- Parameters
arg (Any) – The argument which needs to be checked.
- Raises
TypeError – When the argument is not iterable or the value of the input argument is not string type.
ValueError – When the value of the input argument does not fit the pattern.
- Returns
A list of enum values created by the input argument.
- Return type
List[str]
- class graviti.portex.ptype.Field[source]#
Bases:
ParameterType
Parameter type for Portex record field.
- static check(arg)[source]#
Check and transfer the parameter type.
- Parameters
arg (Any) – The argument which needs to be checked.
- Raises
TypeError – When the input argument is not a tuple of a str and a PortexType.
- Returns
A tuple of str and PortexType created by the input argument.
- Return type
Tuple[str, graviti.portex.base.PortexType]
- static load(content, imports=None)[source]#
Create Portex field instance from python dict.
- Parameters
content (Dict[str, Any]) – A python dict representing a Portex field.
imports (Optional[graviti.portex.package.Imports]) – The imports of the Portex field.
- Returns
A tuple of name and PortexType created from the input python dict.
- Return type
Tuple[str, graviti.portex.base.PortexType]
- static dump(arg)[source]#
Dump the input Portex field instance to a python dict.
- Parameters
arg (Tuple[str, graviti.portex.base.PortexType]) – A tuple of name and PortexType.
- Returns
A Python dict representation of the Portex field.
- Return type
Dict[str, Any]
- class graviti.portex.ptype.Fields[source]#
Bases:
ParameterType
Parameter type for Portex record fields.
- static check(arg)[source]#
Check and transfer the parameter type.
- static load(content, imports=None)[source]#
Create Portex field list instance from python list.
- Parameters
content (List[Any]) – A python list representing a Portex field list.
imports (Optional[graviti.portex.package.Imports]) – The imports of the Portex field.
- Returns
A Portex field list instance created from the input python list.
- Return type
- static dump(arg)[source]#
Dump the input Portex field list instance to a python list.
- Parameters
arg (graviti.portex.field.Fields) – A Portex field list instance.
- Returns
A Python list representation of the Portex field list.
- Return type
List[Any]
- class graviti.portex.ptype.PortexType[source]#
Bases:
ParameterType
Parameter type for Portex type.
- static check(arg)[source]#
Check the parameter type.
- Parameters
arg (Any) – The argument which needs to be checked.
- Returns
The input argument unchanged.
- Raises
TypeError – When the input argument is not a Portex type.
- Return type
- static load(content, imports=None)[source]#
Create Portex type instance from python dict.
- Parameters
content (Dict[str, Any]) – A python dict representing a Portex type.
imports (Optional[graviti.portex.package.Imports]) – The imports of the Portex type.
- Returns
A Portex type instance created from the input python dict.
- Return type
- static dump(arg)[source]#
Dump the instance to a python dict.
- Parameters
arg (graviti.portex.base.PortexType) – A Portex type instance.
- Returns
A python dict representation of the Portex type.
- Return type
Dict[str, Any]