neuralib.argp.core.AbstractParser

class neuralib.argp.core.AbstractParser[source]

Bases: object

DEPRECATED (use the independent package: pip install argclz).

__init__(*args, **kwargs)

Methods

__init__(*args, **kwargs)

main([args, exit_on_error])

parsing the commandline input args and set the argument attributes, then call run().

new_parser(**kwargs)

create an argparse.ArgumentParser.

post_parsing()

called when all argument attributes are set but before run().

run()

called when all argument attributes are set

Attributes

DESCRIPTION

parser description.

EPILOG

parser epilog.

USAGE

parser usage.

USAGE: str = None

parser usage.

DESCRIPTION: str = None

parser description.

EPILOG: str = None

parser epilog. Could be override as a method if its content is dynamic-generated.

static __new__(cls, *args, **kwargs)[source]
classmethod new_parser(**kwargs)[source]

create an argparse.ArgumentParser.

class variable: USAGE, DESCRIPTION and EPILOG are used when creation.

>>> class A(AbstractParser):
...     @classmethod
...     def new_parser(cls, **kwargs) -> argparse.ArgumentParser:
...         return super().new_parser(**kwargs)
Parameters:

kwargs – keyword parameters to ArgumentParser

Returns:

an ArgumentParser.

Return type:

ArgumentParser

main(args=None, *, exit_on_error=True)[source]

parsing the commandline input args and set the argument attributes, then call run().

Example

if overwrite with the argument default, use args

>>> AbstractParser().main((['--source=allen_mouse_25um', '--region=VISal,VISam,...'], []))
Parameters:
  • args (list[str] | tuple[list[str]] | None) – commandline arguments, or a tuple of (prepend, append) arguments

  • exit_on_error (bool) – exit when commandline parsed fail. Otherwise, raise a RuntimeError.

run()[source]

called when all argument attributes are set

post_parsing()[source]

called when all argument attributes are set but before run().

It is used for a common operation for a common option class, for example, checking arguments before doing things.

__init__(*args, **kwargs)