summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Server/Plugin.py')
-rw-r--r--src/lib/Server/Plugin.py35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py
index 11d026c11..1e34b9ca4 100644
--- a/src/lib/Server/Plugin.py
+++ b/src/lib/Server/Plugin.py
@@ -728,7 +728,8 @@ class XMLSrc(XMLFileBacked):
self.priority = int(xdata.get('priority'))
except (ValueError, TypeError):
if not self.noprio:
- logger.error("Got bogus priority %s for file %s" % (xdata.get('priority'), self.name))
+ logger.error("Got bogus priority %s for file %s" %
+ (xdata.get('priority'), self.name))
del xdata, data
def Cache(self, metadata):
@@ -778,16 +779,25 @@ class PrioDir(Plugin, Generator, XMLDirectoryBacked):
except KeyError:
self.Entries[itype] = {child: self.BindEntry}
+ def _matches(self, entry, metadata, rules):
+ return entry.get('name') in rules
+
def BindEntry(self, entry, metadata):
- """Check package lists of package entries."""
- name = entry.get('name')
- if False in [src.Cache(metadata) for src in
- list(self.entries.values())]:
+ attrs = self.get_attrs(entry, metadata)
+ for key, val in list(attrs.items()):
+ entry.attrib[key] = val
+
+ def get_attrs(self, entry, metadata):
+ """ get a list of attributes to add to the entry during the bind """
+ if False in [src.Cache(metadata)
+ for src in list(self.entries.values())]:
self.logger.error("Called before data loaded")
raise PluginExecutionError
matching = [src for src in list(self.entries.values())
- if src.cache and entry.tag in src.cache[1]
- and name in src.cache[1][entry.tag]]
+ if (src.cache and
+ entry.tag in src.cache[1] and
+ self._matches(entry, metadata,
+ src.cache[1][entry.tag]))]
if len(matching) == 0:
raise PluginExecutionError
elif len(matching) == 1:
@@ -804,13 +814,18 @@ class PrioDir(Plugin, Generator, XMLDirectoryBacked):
raise PluginExecutionError
index = prio.index(max(prio))
- data = matching[index].cache[1][entry.tag][name]
+ for rname in matching[index].cache[1][entry.tag]:
+ if self._matches(entry, metadata, rname):
+ data = matching[index].cache[1][entry.tag][rname]
+ break
if '__text__' in data:
entry.text = data['__text__']
if '__children__' in data:
[entry.append(copy.deepcopy(item)) for item in data['__children__']]
- [entry.attrib.__setitem__(key, data[key]) for key in list(data.keys()) \
- if not key.startswith('__')]
+
+ return dict([(key, data[key])
+ for key in list(data.keys())
+ if not key.startswith('__')])
# new unified EntrySet backend