Builder

The Builder module contains functions to convert an XML configuration file into a set of objects that can be used in the event framework.

class BuilderError(Exception):

Custom exception used to report an error when converting an XML file to actual objects. The exception contains the relevant node if applicable.

__init__(value, node=None):
Constructor that specifies the error message, and optionally the node that caused the error.
__str__():
Returns a string representation of the error.
interpolate_text(text, dictionary):
Replace occurances of ${key} with the value of dictionary[key]. This can be used to interpolate text with arbitrary dictionaries such as the os.environ.
get_text(nodelist):
Get the text nodes and concatenate them together. This also includes CDATA sections.
get_child_elements(name, node, first=0):
Gets all children with the specified name. This only works on single level unlike getElementsByTagName. If the optional 'first' argument is true, return only the first element in the list or None if the list is empty.
parse_handler_constructor_args(node):
Create a kwarg map that contains all of the attributes of an element. In addition to attributes, child nodes are also used (and override attribute elements).
parse_handler(node):
Parse a handler object and locate the handler class so an instance can be instantiated with the supplied arguments. A handler type can be specified in either of the following formats: class_name or package_name:class_name. In the first case, the specified class name is searched for in the global namespace. In the latter case, the specified package is searched for the class name. In both cases, as a convienence to users, the type name, if not found is automatically converted to a full name by appending 'EventHandler' to the end of the specified type.
build_error_handler(node):
Scan the node for one or more handlers. If there is only one handler, then that handler is simply returned. However, if there are more than one handlers, they are automatically chained together using a ChainEventHandler.
build_handler(node):
Scan the node for one or more handlers. If there is only one handler, then that handler is simply returned. However, if there are more than one handlers, they are automatically chained together using a ChainEventHandler.
parse_rule(node):
Parse a Rule and verify it specifies a regular expression.
build_rules(node):
Parse all of Rules that are part of this node. It also ensures that at least one rule exists.
parse_logFiles(node):
Scan all of the logFile tags and determine if they should be tracked.
parse_logEncapsulator(node):
Scan a LogEncapsulator and instantiate one that can be returned to the caller.
parse_configuration(root):
Parses an XML document representing the configuration of the logwrap utility. The document is parsed and two items are returned: the error handler used to process errors and a list of encapsulators for the event framework.