argsloader.units.status

ChildPositionUnit

class argsloader.units.status.ChildPositionUnit(*children)[source]
Overview:

Unit for switching position to child level.

__init__(*children)[source]

Constructor of ChildPositionUnit.

Parameters

children – Child levels, multiple levels are supported.

child

argsloader.units.status.child(*children)argsloader.units.status.ChildPositionUnit[source]
Overview:

Switching position to child level, multiple levels are supported.

Parameters

children – Child levels.

Returns

A child position unit.

Examples::
>>> from argsloader.units import child, is_type
>>> u = is_type(int)
>>> u.call(1.0)
argsloader.base.exception.MultipleParseError: (1 error)
  <root>: TypeParseError: Value type not match - int expected but float found.
>>>
>>> u = child('level') >> is_type(int)
>>> u.call(1.0)
argsloader.base.exception.MultipleParseError: (1 error)
  <root>.level: TypeParseError: Value type not match - int expected but float found.
>>>
>>> u = child('level', 2) >> is_type(int)
>>> u.call(1.0)
argsloader.base.exception.MultipleParseError: (1 error)
  <root>.level.2: TypeParseError: Value type not match - int expected but float found.

ParentPositionUnit

class argsloader.units.status.ParentPositionUnit(level)[source]
Overview:

Unit for switching position to parent level.

__init__(level)[source]

Constructor of ParentPositionUnit.

Parameters

level – Number of levels.

parent

argsloader.units.status.parent(level=1)argsloader.units.status.ParentPositionUnit[source]
Overview:

Switching position to parent level, multiple levels are supported.

Parameters

level – Number of levels, default is 1.

Returns

A parent position unit.

Examples::
>>> from argsloader.units import child, is_type, parent
>>> u = child('level', 2) >> is_type(int)
>>> u.call(1.0)  # no parent level, just <root>.level.2
argsloader.base.exception.MultipleParseError: (1 error)
  <root>.level.2: TypeParseError: Value type not match - int expected but float found.
>>>
>>> u = child('level', 2) >> parent() >> is_type(int)
>>> u.call(1.0)  # parent 1 level, <root>.level
argsloader.base.exception.MultipleParseError: (1 error)
  <root>.level: TypeParseError: Value type not match - int expected but float found.
>>>
>>> u = child('level', 2) >> parent(2) >> is_type(int)
>>> u.call(1.0)  # parent 2 levels, <root>
argsloader.base.exception.MultipleParseError: (1 error)
  <root>: TypeParseError: Value type not match - int expected but float found.