summaryrefslogtreecommitdiffstats
path: root/esilib.py
diff options
context:
space:
mode:
Diffstat (limited to 'esilib.py')
-rw-r--r--esilib.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/esilib.py b/esilib.py
index e68b6cd..a9d312f 100644
--- a/esilib.py
+++ b/esilib.py
@@ -105,18 +105,7 @@ class ESIFile:
if not xmlschema.validate(self.dicttree):
error = xmlschema.error_log
logging.error("Validation failed!\n")
- prevmsg = None
- rcnt = 0
- for message in error:
- if str(prevmsg) == str(message):
- rcnt += 1
- else:
- if rcnt != 0:
- logging.error("=== Previous message repated "
- "{} times ===".format(rcnt))
- rcnt = 0
- logging.error(message)
- prevmsg = message
+ _print_uniq(error)
warnings.warn("The output is not a valid ESI!",
InvalidESIWarning)
@@ -445,3 +434,21 @@ def _get_info_tree(canobj):
("DefaultValue", canobj.default),
]
return info
+
+def _print_uniq(messages):
+ prevmsg = None
+ rcnt = 0
+ for message in messages:
+ if str(prevmsg) == str(message):
+ rcnt += 1
+ elif rcnt != 0:
+ logging.error("=== Previous message repated {} times ===".format(
+ rcnt))
+ rcnt = 0
+ logging.error(message)
+ else:
+ logging.error(message)
+ prevmsg = message
+ if rcnt != 0: # Repeating message at the end of the log
+ logging.error("=== Previous message repated {} times ===".format(
+ rcnt))