From b6c566dab0f699e88e744a07424ce933bf73ec6c Mon Sep 17 00:00:00 2001 From: Christopher Usher Date: Sun, 20 Oct 2019 12:48:27 +0100 Subject: [PATCH] warn about and ignore files that don't parse as segments --- common/common/segments.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/common/segments.py b/common/common/segments.py index 950c212..d7d9ccf 100644 --- a/common/common/segments.py +++ b/common/common/segments.py @@ -11,6 +11,7 @@ import logging import os import shutil import sys +import warnings from collections import namedtuple from contextlib import closing @@ -222,7 +223,13 @@ def best_segments_by_start(hour): segment_paths.sort() # note we only parse them as we need them, which is unlikely to save us much time overall # but is easy enough to do, so we might as well. - parsed = (parse_segment_path(os.path.join(hour, name)) for name in segment_paths) + # raise a warning for any files that don't parse as segments and ignore them + parsed = [] + for name in segment_paths: + try: + parsed.append(parse_segment_path(os.path.join(hour, name))) + except ValueError as e: + warnings.warn(e) for start_time, segments in itertools.groupby(parsed, key=lambda segment: segment.start): # ignore temp segments as they might go away by the time we want to use them segments = [segment for segment in segments if segment.type != "temp"]