parsley.config package¶
Submodules¶
parsley.config.config module¶
Parsley configuration handling.
-
class
parsley.config.config.
ParsleyConfiguration
(environment=None)¶ Bases:
object
Representation of a parsley configuration. This class can parse a configuration from xml and can generate it. It also has some modification methods and internal methods for generating actual objects from the data.
- Parameters
environment (Optional[Dict[str, str]]) –
-
class
Aspect
(cfg, otype, **params)¶ Bases:
object
Represents configuration for one aspect.
- Parameters
cfg (ParsleyConfiguration) – The ParsleyConfiguration instance.
otype (str) – The otype name for the new object (i.e. the class name).
params – Additional keyword args are stored as additional config values.
-
static
fromxml
(cfg, xentry)¶ Generates a new configuration object from an xml piece.
- Parameters
xentry (xml.etree.ElementTree.Element) –
- Return type
-
instantiate
(knowntypes)¶ Instantiates a new actual parsley object by this configuration object.
- Parameters
knowntypes (Dict[str, Type]) –
- Return type
-
toxml
(xparent)¶ Generates an xml piece for this object.
- Parameters
xparent (xml.etree.ElementTree.Element) –
- Return type
None
-
class
CustomAspect
(cfg, name, code)¶ Bases:
object
Represents configuration for one custom aspect implementation.
- Parameters
cfg (ParsleyConfiguration) – The ParsleyConfiguration instance.
name (str) – The new otype name (i.e. class name) for this aspect.
code (str) – The implementation source code.
-
static
fromxml
(cfg, xentry)¶ Generates a new configuration object from an xml piece.
- Parameters
xentry (xml.etree.ElementTree.Element) –
- Return type
-
instantiate
(knowntypes)¶ Instantiates a new actual parsley object by this configuration object.
- Parameters
knowntypes (Dict[str, Type]) –
-
toxml
(xparent)¶ Generates an xml piece for this object.
- Parameters
xparent (xml.etree.ElementTree.Element) –
- Return type
None
-
class
Filesystem
(cfg, otype, aspects, **params)¶ Bases:
object
Represents configuration for one filesystem.
- Parameters
cfg (ParsleyConfiguration) – The ParsleyConfiguration instance.
otype (str) – The otype name for the new object (i.e. the class name).
aspects (List[ParsleyConfiguration.Aspect]) – A list of ParsleyConfiguration.Aspect.
params – Additional keyword args are stored as additional config values.
-
static
fromxml
(cfg, xentry)¶ Generates a new configuration object from an xml piece.
- Parameters
xentry (xml.etree.ElementTree.Element) –
- Return type
-
instantiate
(knowntypes)¶ Instantiates a new actual parsley object by this configuration object.
- Parameters
knowntypes (Dict[str, Type]) –
- Return type
-
property
name
¶ - Return type
t.Optional[str]
This property is also settable.
-
toxml
(xparent)¶ Generates an xml piece for this object.
- Parameters
xparent (xml.etree.ElementTree.Element) –
- Return type
None
-
class
Include
(cfg, incpath)¶ Bases:
object
Represents configuration for one config file include.
- Parameters
cfg (ParsleyConfiguration) – The ParsleyConfiguration instance.
incpath (str) – The path to the parsley configuration file for including.
-
static
fromxml
(cfg, xentry)¶ Generates a new configuration object from an xml piece.
- Parameters
xentry (xml.etree.ElementTree.Element) –
- Return type
-
get_absolute_path
(basepath)¶ Returns the absolute path to the file to include.
- Parameters
basepath (str) –
- Return type
str
-
toxml
(xparent)¶ Generates an xml piece for this object.
- Parameters
xparent (xml.etree.ElementTree.Element) –
- Return type
None
-
class
LogFormatter
(cfg, otype, **params)¶ Bases:
object
Represents configuration for one log formatter.
- Parameters
cfg (ParsleyConfiguration) – The ParsleyConfiguration instance.
otype (str) – The otype name for the new object (i.e. the class name).
params – Additional keyword args are stored as additional config values.
-
static
fromxml
(cfg, xentry)¶ Generates a new configuration object from an xml piece.
- Parameters
xentry (xml.etree.ElementTree.Element) –
- Return type
-
instantiate
(knowntypes)¶ Instantiates a new actual parsley object by this configuration object.
- Parameters
knowntypes (Dict[str, Type]) –
- Return type
-
toxml
(xparent)¶ Generates an xml piece for this object.
- Parameters
xparent (xml.etree.ElementTree.Element) –
- Return type
None
-
class
Logger
(cfg, minseverity, maxseverity, loggerout, formatter, enabled)¶ Bases:
object
Represents configuration for one logger.
- Parameters
cfg (ParsleyConfiguration) – The ParsleyConfiguration instance.
minseverity (Optional[str]) – The minimum severity (as parsley.logger.Severity symbol name).
maxseverity (Optional[str]) – The maximum severity (as parsley.logger.Severity symbol name).
loggerout (ParsleyConfiguration.Loggerout) – A ParsleyConfiguration.Loggerout.
formatter (ParsleyConfiguration.LogFormatter) – A ParsleyConfiguration.LogFormatter.
enabled (bool) – If to enable this logger.
-
static
fromxml
(cfg, xentry)¶ Generates a new configuration object from an xml piece.
- Parameters
xentry (xml.etree.ElementTree.Element) –
- Return type
-
instantiate
(knowntypes)¶ Instantiates a new actual parsley object by this configuration object.
- Parameters
knowntypes (Dict[str, Type]) –
- Return type
-
toxml
(xparent)¶ Generates an xml piece for this object.
- Parameters
xparent (xml.etree.ElementTree.Element) –
- Return type
None
-
class
Loggerout
(cfg, otype, **params)¶ Bases:
object
Represents configuration for one logger output.
- Parameters
cfg (ParsleyConfiguration) – The ParsleyConfiguration instance.
otype (str) – The otype name for the new object (i.e. the class name).
params – Additional keyword args are stored as additional config values.
-
static
fromxml
(cfg, xentry)¶ Generates a new configuration object from an xml piece.
- Parameters
xentry (xml.etree.ElementTree.Element) –
- Return type
-
instantiate
(knowntypes)¶ Instantiates a new actual parsley object by this configuration object.
- Parameters
knowntypes (Dict[str, Type]) –
- Return type
-
toxml
(xparent)¶ Generates an xml piece for this object.
- Parameters
xparent (xml.etree.ElementTree.Element) –
- Return type
None
-
class
Preparation
(cfg, otype, **params)¶ Bases:
object
Represents configuration for one synchronization task preparation.
- Parameters
cfg (ParsleyConfiguration) – The ParsleyConfiguration instance.
otype – The otype name for the new object (i.e. the class name).
params – Additional keyword args are stored as additional config values.
-
static
fromxml
(cfg, xentry)¶ Generates a new configuration object from an xml piece.
- Parameters
xentry (xml.etree.ElementTree.Element) –
- Return type
-
instantiate
(knowntypes)¶ Instantiates a new actual parsley object by this configuration object.
- Parameters
knowntypes (Dict[str, Type]) –
- Return type
-
toxml
(xparent)¶ Generates an xml piece for this configuration object.
- Parameters
xparent (xml.etree.ElementTree.Element) –
- Return type
None
-
class
PythonImport
(cfg, importfrom, to)¶ Bases:
object
Represents configuration for one python import.
- Parameters
cfg (ParsleyConfiguration) – The ParsleyConfiguration instance.
importfrom (str) – The full name of the class to import (‘package.module.Class’).
to (str) – The name this class shall have after importing (without dots).
-
static
fromxml
(cfg, xentry)¶ Generates a new configuration object from an xml piece.
- Parameters
xentry (xml.etree.ElementTree.Element) –
- Return type
-
instantiate
()¶ Instantiates a new actual parsley object by this configuration object.
- Return type
Any
-
toxml
(xparent)¶ Generates an xml piece for this object.
- Parameters
xparent (xml.etree.ElementTree.Element) –
- Return type
None
-
class
Sync
(cfg, filesystems, aspects, preparations, **params)¶ Bases:
object
Represents configuration for one synchronization task.
- Parameters
cfg (ParsleyConfiguration) – The ParsleyConfiguration instance.
filesystems (List[ParsleyConfiguration.Filesystem]) – A list of ParsleyConfiguration.Filesystem.
aspects (List[ParsleyConfiguration.Aspect]) – A list of ParsleyConfiguration.Aspect.
preparations (List[ParsleyConfiguration.Preparation]) – A list of ParsleyConfiguration.Preparation.
params – Additional keyword args are stored as additional config values.
-
_aspectlist
(fs=None)¶ Returns either the aspect list for fs, or the global one if fs=None.
- Parameters
fs (Optional[int]) –
- Return type
-
addaspect
(otype, fs=None, **params)¶ Adds a new aspect.
- Parameters
otype (str) – The otype name for the new aspect (i.e. the class name).
fs (Optional[int]) – Adds to this filesystem’s aspect list, None for global.
params – Additional keyword args are stored as additional config values.
- Return type
-
static
fromxml
(cfg, xentry)¶ Generates a new configuration object from an xml piece.
- Parameters
xentry (xml.etree.ElementTree.Element) –
- Return type
-
getaspects
(otype, fs=None, everywhere=False)¶ Returns all aspects with otype name otype (i.e. the class name).
- Parameters
otype (str) – The otype name.
fs (Optional[int]) – Whose aspect list to consider, None for the global one.
everywhere (bool) – If True, all aspect lists are considered; ignores fs.
- Return type
-
hasaspect
(otype, fs=None, everywhere=False)¶ Checks if an aspect with otype name otype (i.e. the class name) exists.
- Parameters
otype (str) – The otype name.
fs (Optional[int]) – Whose aspect list to consider, None for the global one.
everywhere (bool) – If True, all aspect lists are considered; ignores fs.
- Return type
bool
-
instantiate
(knowntypes)¶ Instantiates a new actual parsley object by this configuration object.
- Parameters
knowntypes (Dict[str, Type]) –
- Return type
-
property
name
¶ - Return type
t.Optional[str]
This property is also settable.
-
removeaspect
(otype, fs=None, everywhere=False)¶ Removes all aspects with otype name otype (i.e. the class name).
- Parameters
otype (str) – The otype name.
fs (Optional[int]) – Whose aspect list to consider, None for the global one.
everywhere (bool) – If True, all aspect lists are considered; ignores fs.
- Return type
None
-
toxml
(xparent)¶ Generates an xml piece for this object.
- Parameters
xparent (xml.etree.ElementTree.Element) –
- Return type
None
-
property
customaspects
¶ - Return type
t.List[‘ParsleyConfiguration.CustomAspect’]
-
property
environment
¶ - Return type
t.Dict[str, str]
-
static
fromxml
(xmlstring, environment=None)¶ Generates a ParsleyConfiguration from an xml string.
- Parameters
xmlstring (str) –
environment (Optional[Dict[str, str]]) –
- Return type
-
property
includes
¶ - Return type
t.List[‘ParsleyConfiguration.Include’]
-
property
loggers
¶ - Return type
t.List[‘ParsleyConfiguration.Logger’]
-
parseparams
(d)¶ Interprets a complete dictionary by the same replacement as in ParsleyConfiguration.parsestring.
- Parameters
d (Dict[str, str]) –
- Return type
Dict[str, str]
-
parsestring
(s)¶ ” Interprets a string by replacing each ${FOO} with the value of the os environmental variable FOO.
- Parameters
s (str) –
- Return type
str
-
property
pythonimports
¶ - Return type
t.List[‘ParsleyConfiguration.PythonImport’]
-
property
syncs
¶ - Return type
t.List[‘ParsleyConfiguration.Sync’]
-
toxml
()¶ Returns an xml representation for the current configuration.
- Return type
str
parsley.config.configpiece module¶
Helpers for Parsley configuration handling.
-
parsley.config.configpiece.
getbool
(s)¶ If s is a bool, it is returned directly, otherwise it is parsed from string.
- Parameters
s (Any) –
- Return type
bool
-
parsley.config.configpiece.
getcallable
(s, argnames)¶ If s is a callable, it is returned directly, otherwise it is parsed from string.
- Parameters
s (Any) –
argnames (List[str]) –
- Return type
Callable
-
parsley.config.configpiece.
getlist
(kwa, listname)¶ Returns a list from a keyword-args structure either by direct lookup or by flattened lookup (foo_0, foo_1, foo_2, …, foo_n).
- Parameters
kwa (Dict[str, Optional[Any]]) –
listname (str) –
- Return type
List[str]
-
parsley.config.configpiece.
gettimedelta
(s)¶ If s is a datetime.timedelta, it is returned directly, otherwise it is parsed from string.
- Parameters
s (Any) –
- Return type
datetime.timedelta
Module contents¶
Parsley configuration.