SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
sourcextractor.config.argv.Arguments Class Reference
Inheritance diagram for sourcextractor.config.argv.Arguments:
Collaboration diagram for sourcextractor.config.argv.Arguments:

Public Member Functions

 __init__ (self, **kwargs)
 __getattr__ (self, item)
 __str__ (self)
 __repr__ (self)

Private Attributes

 __args = dict()

Detailed Description

This helper class automatically parses the arguments received by the Python script via
sys.argv, using the set of key-value parameters received on its constructor to cast the types
and define the defaults.

Parameters
----------
kwargs
    A set of key-values with the defaults, or the types of the expected values. For instance, it is valid to do
    both:

    key1 = 32.
    key2 = float

    For the first case - a value -, if no value is passed via sys.argv, this will be the default. Otherwise,
    its type (float) will be used to cast the received value.

    For the second case - a type -, if no value is passed via sys.argv, the parameter will default to None.
    Otherwise, the type will be used to cast the received value.

    Callables are also accepted. They should accept to be called with no parameters, returning the default,
    or with a single string, returning the parsed value.

    Values can be accessed later as attributes:

    instance.key1 and instance.key2

Raises
------
ValueError
    If the cast of the parameter failed (i.e. an invalid integer or float format)
KeyError
    If additional unknown parameters are received

Definition at line 22 of file argv.py.

Constructor & Destructor Documentation

◆ __init__()

sourcextractor.config.argv.Arguments.__init__ ( self,
** kwargs )
Constructor.

Definition at line 58 of file argv.py.

Member Function Documentation

◆ __getattr__()

sourcextractor.config.argv.Arguments.__getattr__ ( self,
item )
Parameters
----------
item : str
    Name of the parameter to retrieve

Returns
-------
    The parsed value of the parameter

Raises
------
AttributeError
    If item has not been defined on construction

Definition at line 88 of file argv.py.

References __args.

◆ __repr__()

sourcextractor.config.argv.Arguments.__repr__ ( self)
Returns
-------
str
    String representation for the object

Definition at line 118 of file argv.py.

References __args.

◆ __str__()

sourcextractor.config.argv.Arguments.__str__ ( self)
Returns
-------
str
    Human readable representation for the object

Definition at line 109 of file argv.py.

References __args.

Member Data Documentation

◆ __args

sourcextractor.config.argv.Arguments.__args = dict()
private

Definition at line 64 of file argv.py.

Referenced by __getattr__(), __repr__(), and __str__().


The documentation for this class was generated from the following file: