SourceXtractorPlusPlus  0.11
Please provide a description of the project.
Public Member Functions | Private Attributes | List of all members
sourcextractor.config.argv.Arguments Class Reference
Inheritance diagram for sourcextractor.config.argv.Arguments:
[legend]
Collaboration diagram for sourcextractor.config.argv.Arguments:
[legend]

Public Member Functions

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

Private Attributes

 __args
 

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__()

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

Definition at line 58 of file argv.py.

Member Function Documentation

◆ __getattr__()

def 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 sourcextractor.config.argv.Arguments.__args.

◆ __repr__()

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

Definition at line 118 of file argv.py.

References sourcextractor.config.argv.Arguments.__args.

◆ __str__()

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

Definition at line 109 of file argv.py.

References sourcextractor.config.argv.Arguments.__args.

Member Data Documentation

◆ __args

sourcextractor.config.argv.Arguments.__args
private

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