# HG changeset patch # User Tero Marttila # Date 1357833163 -7200 # Node ID 2e675eda5e332abc4cc02df53aea62bc90c25373 # Parent 952ee07efd7a86865f0d70fa874c12598b1cd127 remove accidential .pp file diff -r 952ee07efd7a -r 2e675eda5e33 pvl/syslog/rule.pp --- a/pvl/syslog/rule.pp Thu Jan 10 17:51:53 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -class SyslogRule (SyslogFilter) : - """ - A rule matches syslog lines, and formats them. - - tag - apply given tag to matches - """ - - def __init__ (self, tag, program=None, pattern=None, format=None, flags=None, **opts) : - if pattern and not isinstance(pattern, re.RegexObject) : - pattern = re.compile(pattern, flags) - - super(SyslogRule, self).__init__(prog=program) - - self.tag = tag - self.format = format - self.pattern = pattern - - def apply (self, item) : - """ - Apply rule against given item. - """ - - # filter - match = self.filter(item) - - if not match : - # ignore - return None - - match = self.pattern.match(item['msg']) - - if not match : - # ignore - return None - - # apply - item.update(match.groupdict()) - - if self.tag is False : - # drop - return False - - if self.format : - # return - return self.tag, self.format.format(**item) -