Commit 748ee91c authored by Ryan Herbert's avatar Ryan Herbert

vidjilparser.py minor optimise _extract condition

group all checks into a single call to any, to avoid multiple iterations
over the same data.
Also remove some comparisons that don't seem necessary.
parent 50ac211a
......@@ -151,13 +151,11 @@ class VidjilParser(object):
previous = ''
res = ""
for prefix, event, value in parser:
#There must be a better way !!!
cond = any(prefix.startswith(item[0]) for item in self.prefixes) \
or (any(item[0].startswith(prefix) for item in self.prefixes) \
and (value is None \
or any(item[0].startswith(prefix + '.' + str(value)) for item in self.prefixes) \
or any(item[0].startswith(str(value)) for item in self.prefixes)))
if cond:
subelem = lambda x, y: x.startswith(y)
if any(subelem(prefix, item[0])\
or (subelem(item[0], prefix) and (value is None or subelem(item[0], str(value))))\
for item in self.prefixes):
if not self._writer.conserveBuffer \
and any((item[1].compare(prefix, value)) for item in self.prefixes):
self._writer.conserveBuffer = True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment