carputils
Doxygen code documentation for the python framework controlling openCARP
|
Settings namespace object. More...
Public Member Functions | |
def | __init__ (self, missing_error=True, errortype=AttributeError) |
def | get (self, key, fallback=None) |
Get an item without raising errors when missing, like dict().get() More... | |
def | __getattr__ (self, attr) |
Custom attribute access code providing case-insensitivity. More... | |
def | __getitem__ (self, key) |
Allow object to be used like dict. More... | |
def | __setattr__ (self, attr, value) |
Custom attribute access code providing case-insensitivity and order logging. More... | |
def | __setitem__ (self, key, value) |
Allow object to be used like dict. More... | |
def | __iter__ (self) |
Return iterator over settings. More... | |
def | __str__ (self) |
Settings namespace object.
Objects of this class provide a case-insensitive namespace, which can be access either through attributes or as a dict. For example, an object created like:
can then be assigned values like::
and accessed like:
Attributes/keys are case insensitive:
Use of the attribute method of accessing values is recommended, as this reflects the object's intended use as a container of 'constants' in the rest of the code. dict-like access is implemented for backwards compatibility.
missing_error bool, optional Raise an Exception when a requested attribute is missing or None (default: True) errortype Exception, optional Type of exception to raise when an item is missing or None (default; AttributeError)
def carputils.settings.namespace.SettingsNamespace.__init__ | ( | self, | |
missing_error = True , |
|||
errortype = AttributeError |
|||
) |
def carputils.settings.namespace.SettingsNamespace.__getattr__ | ( | self, | |
attr | |||
) |
Custom attribute access code providing case-insensitivity.
def carputils.settings.namespace.SettingsNamespace.__getitem__ | ( | self, | |
key | |||
) |
Allow object to be used like dict.
def carputils.settings.namespace.SettingsNamespace.__iter__ | ( | self | ) |
Return iterator over settings.
def carputils.settings.namespace.SettingsNamespace.__setattr__ | ( | self, | |
attr, | |||
value | |||
) |
Custom attribute access code providing case-insensitivity and order logging.
def carputils.settings.namespace.SettingsNamespace.__setitem__ | ( | self, | |
key, | |||
value | |||
) |
Allow object to be used like dict.
def carputils.settings.namespace.SettingsNamespace.__str__ | ( | self | ) |
def carputils.settings.namespace.SettingsNamespace.get | ( | self, | |
key, | |||
fallback = None |
|||
) |
Get an item without raising errors when missing, like dict().get()
key str Key of item to return (case-insensitive) fallback object, optional Value to return when key is missing (default: None)