From 7e6a3015cd61fb794fe299df9783099a4a792ec8 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Mon, 1 Aug 2011 13:58:34 -0400 Subject: split up XMLSrc parsers used for Rules and info.xml --- src/lib/Server/Plugin.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/lib/Server/Plugin.py') diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py index a79fac0e1..0f45f53f1 100644 --- a/src/lib/Server/Plugin.py +++ b/src/lib/Server/Plugin.py @@ -600,12 +600,10 @@ class INode: group intersection. """ raw = {'Client': "lambda m, e:'%(name)s' == m.hostname and predicate(m, e)", - 'Group': "lambda m, e:'%(name)s' in m.groups and predicate(m, e)", - 'Path': "lambda m, e:('%(name)s' == e.get('name') or '%(name)s' == e.get('realname')) and predicate(m, e)"} + 'Group': "lambda m, e:'%(name)s' in m.groups and predicate(m, e)"} nraw = {'Client': "lambda m, e:'%(name)s' != m.hostname and predicate(m, e)", - 'Group': "lambda m, e:'%(name)s' not in m.groups and predicate(m, e)", - 'Path': "lambda m, e:('%(name)s' != e.get('name') and '%(name)s' != e.get('realname')) and predicate(m, e)"} - containers = ['Group', 'Client', 'Path'] + 'Group': "lambda m, e:'%(name)s' not in m.groups and predicate(m, e)"} + containers = ['Group', 'Client'] ignore = [] def __init__(self, data, idict, parent=None): @@ -657,6 +655,17 @@ class INode: child.Match(metadata, data, entry=entry) +class InfoNode (INode): + """ INode implementation that includes tags """ + raw = {'Client': "lambda m, e:'%(name)s' == m.hostname and predicate(m, e)", + 'Group': "lambda m, e:'%(name)s' in m.groups and predicate(m, e)", + 'Path': "lambda m, e:('%(name)s' == e.get('name') or '%(name)s' == e.get('realname')) and predicate(m, e)"} + nraw = {'Client': "lambda m, e:'%(name)s' != m.hostname and predicate(m, e)", + 'Group': "lambda m, e:'%(name)s' not in m.groups and predicate(m, e)", + 'Path': "lambda m, e:('%(name)s' != e.get('name') and '%(name)s' != e.get('realname')) and predicate(m, e)"} + containers = ['Group', 'Client', 'Path'] + + class XMLSrc(XMLFileBacked): """XMLSrc files contain a LNode hierarchy that returns matching entries.""" __node__ = INode @@ -704,6 +713,10 @@ class XMLSrc(XMLFileBacked): self.cache = cache +class InfoXML (XMLSrc): + __node__ = InfoNode + + class XMLDirectoryBacked(DirectoryBacked): """Directorybacked for *.xml.""" patterns = re.compile('.*\.xml') -- cgit v1.2.3-1-g7c22