Package logsparser :: Module normalizer :: Class Normalizer

[frames] | no frames]

# Class Normalizer

source code

    object --+
             |
            Normalizer

Log Normalizer, based on an XML definition file.

Instance Methods

__init__(self, xmlconf, genericTagTypes, genericCallBacks) initializes the normalizer with an lxml ElementTree. | source code

get_description(self, language=`'``en``'`) | source code

get_long_description(self, language=`'``en``'`) | source code

get_uncompiled_regexp(self, p=None, increment=0) returns the uncompiled regular expression associated to pattern named p. | source code

normalize(self, log, do_not_check_prereq=False) normalization in standalone mode. | source code

validate(self) if the definition file comes with pattern examples, this method can be invoked to test these patterns against the examples. | source code

get_source(self) gets the raw XML source for this normalizer. | source code

get_languages(self) guesstimates the available languages from the description field and returns them as a list. | source code

Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, xmlconf, genericTagTypes, genericCallBacks)
(Constructor)

source code

initializes the normalizer with an lxml ElementTree.

Parameters:
  - `xmlconf` - lxml ElementTree normalizer definition
  - `genericTagTypes` - path to generic tags definition xml file
Overrides: object.__init__

### get_uncompiled_regexp(self, p=None, increment=0)

source code

returns the uncompiled regular expression associated to pattern named p. If p is None, all patterns are stitched together, ready for compilation. increment is the starting value to use for the generic tag names in the returned regular expression.

Returns:
  regexp, dictionary of tag names <-> tag codes, dictionary of tags codes <-> pattern the tag came from, new increment value

### normalize(self, log, do_not_check_prereq=False)

source code

normalization in standalone mode.

Parameters:
  - `log` - a dictionary or an object providing at least a get() method
  - `do_not_check_prereq` - if set to True, the prerequisite tags check is skipped (debug purpose only)
Returns:
  a dictionary with updated tags if normalization was successful.

### validate(self)

source code

if the definition file comes with pattern examples, this method can be invoked to test these patterns against the examples. Note that tags not included in the "expectedTags" directives will not be checked for validation.

Returns:
  True if the normalizer is validated, raises a ValueError describing the problem otherwise.