argsloader.units.base¶
UncompletedUnit¶
-
class
argsloader.units.base.UncompletedUnit[source]¶ - Overview:
Uncompleted unit class, used when some unit structure is not completed.
-
__call__(v)[source]¶ Calculate with given value.
Warning
This will fail due to its incompleteness.
- Parameters
v – Input value.
- Returns
Output value.
- Raises
SyntaxError – Unit syntax error.
-
_fail()[source]¶ Fail method, should raise error when this uncompleted unit is used.
- Raises
SyntaxError – Unit syntax error.
-
call(v, err_mode='ALL')[source]¶ Calculate with given value, similar to
__call__().Warning
This will fail due to its incompleteness.
- Parameters
v – Input value.
err_mode – Error mode, see
argsloader.base.result.ErrMode.
- Raises
SyntaxError – Unit syntax error.
-
log(v) → argsloader.base.result.ParseResult[source]¶ Get full log of this parsing process.
Warning
This will fail due to its incompleteness.
- Parameters
v – Input value.
- Raises
SyntaxError – Unit syntax error.
-
property
optional¶ Optional unit of this unit.
See
argsloader.units.common.optional().Warning
This will fail due to its incompleteness.
-
property
validity¶ Validity of this unit.
See
argsloader.units.utils.validity().Warning
This will fail due to its incompleteness.
BaseUnit¶
-
class
argsloader.units.base.BaseUnit[source]¶ -
__and__(other) → argsloader.units.base.BaseUnit[source]¶ Build and-liked unit within units, like
self & other.See
argsloader.units.operator.and_().- Parameters
other – Another unit.
- Returns
And-linked unit.
-
__call__(v)[source]¶ Calculate with given value.
- Parameters
v – Input value.
- Returns
Output value.
- Raises
ParseError – Parse error.
-
__or__(other) → argsloader.units.base.BaseUnit[source]¶ Build or-liked unit within units, like
self | other.See
argsloader.units.operator.or_().- Parameters
other – Another unit.
- Returns
Or-linked unit.
-
__rand__(other) → argsloader.units.base.BaseUnit[source]¶ Right version of
__and__(), likeother & self.- Parameters
other – Another unit.
- Returns
And-linked unit.
-
__ror__(other) → argsloader.units.base.BaseUnit[source]¶ Right version of
__or__(), likeother | self.See
argsloader.units.operator.or_().- Parameters
other – Another unit.
- Returns
Or-linked unit.
-
__rrshift__(other) → argsloader.units.base.BaseUnit[source]¶ Right version of
__rshift__(), likeother >> self.- Parameters
other – Another unit.
- Returns
Piped unit.
-
__rshift__(other) → argsloader.units.base.BaseUnit[source]¶ Build pipe within units, like
self >> other.See
argsloader.units.operator.pipe().- Parameters
other – Another unit.
- Returns
Piped unit.
-
_easy_process(v: argsloader.base.value.PValue, proxy: argsloader.units.base.UnitProcessProxy) → argsloader.base.result.ParseResult[source]¶ Easy process method,
proxycan be used to quickly build parse result object.- Parameters
v –
PValueobject.proxy – Proxy object.
- Returns
Parse result object.
-
_process(v: argsloader.base.value.PValue) → argsloader.base.result.ParseResult[source]¶ Protected process method.
- Parameters
v –
PValueinput object.- Returns
Parse result object.
-
_skip(v: argsloader.base.value.PValue) → argsloader.base.result.ParseResult[source]¶ Create a skipped result
- Parameters
v –
PValueobject.- Returns
Skipped parse result object.
-
call(v, err_mode='ALL')[source]¶ Calculate with given value, similar to
__call__().- Parameters
v – Input value.
err_mode – Error mode, see
argsloader.base.result.ErrMode, default isALL.
- Returns
Output value.
- Raises
ParseError – Parse error.
MultipleParseError – Indexed parsed error, will be raised when
ALLmode is used.
-
log(v) → argsloader.base.result.ParseResult[source]¶ Get full log of this parsing process.
- Parameters
v – Input value.
- Returns
Parse result.
-
property
optional¶ Optional unit of this unit.
-
property
validity¶ Validity of this unit.
-
UnitProcessProxy¶
-
class
argsloader.units.base.UnitProcessProxy(unit: argsloader.units.base.BaseUnit, v: argsloader.base.value.PValue)[source]¶ - Overview:
Proxy class, used to create result object.
-
__init__(unit: argsloader.units.base.BaseUnit, v: argsloader.base.value.PValue)[source]¶ Constructor of class
argsloader.units.base.UnitProcessProxy.- Parameters
unit – Unit object.
v –
PValueobject.
-
error(err, children=None) → argsloader.base.result.ParseResult[source]¶ Build an error result.
- Parameters
err – Error object, will be transformed to
argsloader.base.exception.ParseErrorif it is not yet.children – Children objects.
- Returns
Error parse result.
-
skipped() → argsloader.base.result.ParseResult[source]¶ Build a skipped result.
- Returns
Skipped parse result.
-
success(res: argsloader.base.value.PValue, children=None) → argsloader.base.result.ParseResult[source]¶ Build a success result.
- Parameters
res –
PValueresult object.children – Children objects.
- Returns
Success parse result.
ValueUnit¶
-
class
argsloader.units.base.ValueUnit(value)[source]¶ - Overview:
Raw value unit.
-
__init__(value)[source]¶ Constructor of class
argsloader.units.base.ValueUnit.- Parameters
value – Raw value.
-
_easy_process(v: argsloader.base.value.PValue, proxy: argsloader.units.base.UnitProcessProxy) → argsloader.base.result.ParseResult[source]¶ Easy process method,
proxycan be used to quickly build parse result object.- Parameters
v –
PValueobject.proxy – Proxy object.
- Returns
Parse result object.
raw¶
-
argsloader.units.base.raw(v) → argsloader.units.base.ValueUnit[source]¶ Raw value unit.
- Parameters
v – Original value.
- Returns
raw value unit.