CedarBackup2.extend.mbox.LocalConfig

Package CedarBackup2 :: Package extend :: Module mbox :: Class LocalConfig |
[hide private]
[frames] | no frames]

# Class LocalConfig

source code

    object --+
             |
            LocalConfig

Class representing this extension's configuration document.

This is not a general-purpose configuration object like the main Cedar Backup configuration object. Instead, it just knows how to parse and emit Mbox-specific configuration values. Third parties who need to read and write configuration related to this extension should access it through the constructor, `validate` and `addConfig` methods.

Note: Lists within this class are "unordered" for equality comparisons.

Instance Methods | [hide private]
__init__(self, xmlData=None, xmlPath=None, validate=True) Initializes a configuration object. | source code
__repr__(self) Official string representation for class instance. | source code
__str__(self) Informal string representation for class instance. | source code
__cmp__(self, other) Definition of equals operator for this class. | source code
validate(self) Validates configuration represented by the object. | source code
addConfig(self, xmlDom, parentNode) Adds an <mbox> configuration section as the next child of a parent. | source code
_setMbox(self, value) Property target used to set the mbox configuration value. | source code
_getMbox(self) Property target used to get the mbox configuration value. | source code
_parseXmlData(self, xmlData) Internal method to parse an XML string into the object. | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__subclasshook__`

Static Methods | [hide private]
_parseMbox(parent) Parses an mbox configuration section. | source code
_parseMboxFiles(parent) Reads a list of `MboxFile` objects from immediately beneath the parent. | source code
_parseMboxDirs(parent) Reads a list of `MboxDir` objects from immediately beneath the parent. | source code
_parseExclusions(parentNode) Reads exclusions data from immediately beneath the parent. | source code
_addMboxFile(xmlDom, parentNode, mboxFile) Adds an mbox file container as the next child of a parent. | source code
_addMboxDir(xmlDom, parentNode, mboxDir) Adds an mbox directory container as the next child of a parent. | source code

Properties | [hide private]
| mbox Mbox configuration in terms of a `MboxConfig` object.
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, xmlData=None, xmlPath=None, validate=True) (Constructor) | source code
Initializes a configuration object. If you initialize the object without passing either `xmlData` or `xmlPath` then configuration will be empty and will be invalid until it is filled in properly. No reference to the original XML data or original path is saved off by this class. Once the data has been parsed (successfully or not) this original information is discarded. Unless the `validate` argument is `False`, the LocalConfig.validate method will be called (with its default arguments) against configuration after successfully parsing any passed-in XML. Keep in mind that even if `validate` is `False`, it might not be possible to parse the passed-in XML document if lower-level validations fail. Parameters: `xmlData` (String data.) - XML data representing configuration. `xmlPath` (Absolute path to a file on disk.) - Path to an XML file on disk. `validate` (Boolean true/false.) - Validate the document after parsing it. Raises: `ValueError` - If both `xmlData` and `xmlPath` are passed-in. `ValueError` - If the XML data in `xmlData` or `xmlPath` cannot be parsed. `ValueError` - If the parsed configuration document is not valid. Overrides: object.__init__ Note: It is strongly suggested that the `validate` option always be set to `True` (the default) unless there is a specific need to read in invalid configuration from disk.

### __repr__(self) (Representation operator) | source code
Official string representation for class instance. Overrides: object.__repr__

### __str__(self) (Informal representation operator) | source code
Informal string representation for class instance. Overrides: object.__str__

### __cmp__(self, other) (Comparison operator) | source code
Definition of equals operator for this class. Lists within this class are "unordered" for equality comparisons. Parameters: `other` - Other object to compare to. Returns: -1/0/1 depending on whether self is `<`, `=` or `>` other.

### validate(self) | source code
Validates configuration represented by the object. Mbox configuration must be filled in. Within that, the collect mode and compress mode are both optional, but the list of repositories must contain at least one entry. Each configured file or directory must contain an absolute path, and then must be either able to take collect mode and compress mode configuration from the parent `MboxConfig` object, or must set each value on its own. Raises: `ValueError` - If one of the validations fails.

### addConfig(self, xmlDom, parentNode) | source code
Adds an <mbox> configuration section as the next child of a parent. Third parties should use this function to write configuration related to this extension. We add the following fields to the document:
      collectMode    //cb_config/mbox/collectMode
      compressMode   //cb_config/mbox/compressMode
We also add groups of the following items, one list element per item:
      mboxFiles      //cb_config/mbox/file
      mboxDirs       //cb_config/mbox/dir
The mbox files and mbox directories are added by _addMboxFile and _addMboxDir. Parameters: `xmlDom` - DOM tree as from `impl.createDocument()`. `parentNode` - Parent that the section should be appended to.

### _setMbox(self, value) | source code
Property target used to set the mbox configuration value. If not `None`, the value must be a `MboxConfig` object. Raises: `ValueError` - If the value is not a `MboxConfig`

### _parseXmlData(self, xmlData) | source code
Internal method to parse an XML string into the object. This method parses the XML document into a DOM tree (`xmlDom`) and then calls a static method to parse the mbox configuration section. Parameters: `xmlData` (String data) - XML data to be parsed Raises: `ValueError` - If the XML cannot be successfully parsed.

### _parseMbox(parent) Static Method | source code
Parses an mbox configuration section. We read the following individual fields:
      collectMode    //cb_config/mbox/collect_mode
      compressMode   //cb_config/mbox/compress_mode
We also read groups of the following item, one list element per item:
      mboxFiles      //cb_config/mbox/file
      mboxDirs       //cb_config/mbox/dir
The mbox files are parsed by _parseMboxFiles and the mbox directories are parsed by _parseMboxDirs. Parameters: `parent` - Parent node to search beneath. Returns: `MboxConfig` object or `None` if the section does not exist. Raises: `ValueError` - If some filled-in value is invalid.

### _parseMboxFiles(parent) Static Method | source code
Reads a list of `MboxFile` objects from immediately beneath the parent. We read the following individual fields:
      absolutePath            abs_path
      collectMode             collect_mode
      compressMode            compess_mode
Parameters: `parent` - Parent node to search beneath. Returns: List of `MboxFile` objects or `None` if none are found. Raises: `ValueError` - If some filled-in value is invalid.

### _parseMboxDirs(parent) Static Method | source code
Reads a list of `MboxDir` objects from immediately beneath the parent. We read the following individual fields:
      absolutePath            abs_path
      collectMode             collect_mode
      compressMode            compess_mode
We also read groups of the following items, one list element per item:
      relativeExcludePaths    exclude/rel_path
      excludePatterns         exclude/pattern
The exclusions are parsed by _parseExclusions. Parameters: `parent` - Parent node to search beneath. Returns: List of `MboxDir` objects or `None` if none are found. Raises: `ValueError` - If some filled-in value is invalid.

### _parseExclusions(parentNode) Static Method | source code
Reads exclusions data from immediately beneath the parent. We read groups of the following items, one list element per item:
      relative    exclude/rel_path
      patterns    exclude/pattern
If there are none of some pattern (i.e. no relative path items) then `None` will be returned for that item in the tuple. Parameters: `parentNode` - Parent node to search beneath. Returns: Tuple of (relative, patterns) exclusions.

### _addMboxFile(xmlDom, parentNode, mboxFile) Static Method | source code
Adds an mbox file container as the next child of a parent. We add the following fields to the document:
      absolutePath            file/abs_path
      collectMode             file/collect_mode
      compressMode            file/compress_mode
The <file> node itself is created as the next child of the parent node. This method only adds one mbox file node. The parent must loop for each mbox file in the `MboxConfig` object. If `mboxFile` is `None`, this method call will be a no-op. Parameters: `xmlDom` - DOM tree as from `impl.createDocument()`. `parentNode` - Parent that the section should be appended to. `mboxFile` - MboxFile to be added to the document.

### _addMboxDir(xmlDom, parentNode, mboxDir) Static Method | source code
Adds an mbox directory container as the next child of a parent. We add the following fields to the document:
      absolutePath            dir/abs_path
      collectMode             dir/collect_mode
      compressMode            dir/compress_mode
We also add groups of the following items, one list element per item:
      relativeExcludePaths    dir/exclude/rel_path
      excludePatterns         dir/exclude/pattern
The <dir> node itself is created as the next child of the parent node. This method only adds one mbox directory node. The parent must loop for each mbox directory in the `MboxConfig` object. If `mboxDir` is `None`, this method call will be a no-op. Parameters: `xmlDom` - DOM tree as from `impl.createDocument()`. `parentNode` - Parent that the section should be appended to. `mboxDir` - MboxDir to be added to the document.

Property Details | [hide private]

### mbox Mbox configuration in terms of a `MboxConfig` object. Get Method: _getMbox(self) - Property target used to get the mbox configuration value. Set Method: _setMbox(self, value) - Property target used to set the mbox configuration value.