graviti.portex.ptype#

Parameter type releated classes.

Module Contents#

Classes#

ParameterType

The base class of parameter type.

Any

Unconstrained parameter type.

Boolean

Parameter type for JSON Boolean.

Array

Parameter type for JSON Array.

Mapping

Parameter type for JSON object.

Number

Parameter type for JSON number.

Integer

Parameter type for JSON integer.

String

Parameter type for JSON string.

Enum

Parameter type for Portex enum values.

Fields

Parameter type for Portex record fields.

PortexType

Parameter type for Portex type.

Attributes#

class graviti.portex.ptype.ParameterType[source]#

The base class of parameter type.

static check(arg)[source]#

Check the parameter type.

Parameters

arg (Any) – The argument which needs to be checked.

Returns

The input argument unchanged.

Return type

Any

static load(content, _=None)[source]#

Create an instance of the parameter type from the python content.

Parameters
Returns

An instance of the parameter type.

Return type

Any

static dump(arg)[source]#

Dump the parameter type instance into the python presentation.

Parameters

arg (Any) – The parameter type instance.

Returns

The python presentation of the input instance.

Return type

Any

graviti.portex.ptype.PType[source]#
class graviti.portex.ptype.Any[source]#

Bases: ParameterType

Unconstrained parameter type.

class graviti.portex.ptype.Boolean[source]#

Bases: _JsonType

Parameter type for JSON Boolean.

class graviti.portex.ptype.Array[source]#

Bases: _JsonType

Parameter type for JSON Array.

class graviti.portex.ptype.Mapping[source]#

Bases: _JsonType

Parameter type for JSON object.

class graviti.portex.ptype.Number[source]#

Bases: _JsonType

Parameter type for JSON number.

class graviti.portex.ptype.Integer[source]#

Bases: _JsonType

Parameter type for JSON integer.

class graviti.portex.ptype.String[source]#

Bases: _JsonType

Parameter type for JSON string.

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.

Returns

A list of enum values created by the input argument.

Return type

graviti.portex.enum.EnumValues

static load(content, _=None)[source]#

Create Portex EnumValues instance from python object.

Parameters
  • content (Union[Dict[int, graviti.portex.enum.EnumValueType], List[graviti.portex.enum.EnumValueType], None]) – A python list or dict representing a EnumValues.

  • _ (Optional[graviti.portex.package.Imports]) – The imports of the Portex field.

Returns

A Portex EnumValues instance created from the input python list or dict.

Raises

TypeError – When the input enum values is not in list or dict format.

Return type

Optional[graviti.portex.enum.EnumValues]

static dump(arg)[source]#

Dump the input Portex EnumValues instance to a python list or dict.

Parameters

arg (graviti.portex.enum.EnumValues) – A Portex EnumValues instance.

Returns

A Python list or dict representation of the Portex enum values.

Return type

Union[Dict[int, graviti.portex.enum.EnumValueType], List[graviti.portex.enum.EnumValueType]]

class graviti.portex.ptype.Fields[source]#

Bases: ParameterType

Parameter type for Portex record fields.

static check(arg)[source]#

Check and transfer the parameter type.

Parameters

arg (Any) – The argument which needs to be checked.

Returns

A Fields instance created by the input argument.

Return type

graviti.portex.field.Fields

static load(content, imports=None)[source]#

Create Portex field list instance from python list.

Parameters
  • content (Optional[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

graviti.portex.field.Fields

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

graviti.portex.base.PortexType

static load(content, imports=None)[source]#

Create Portex type instance from python dict.

Parameters
  • content (Optional[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

Optional[graviti.portex.base.PortexType]

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]