Commit b925093e authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files load() calls either load_vidjil() or load_clntab()

Previously, load_clntab() was launched when there was an exception raised by load_vidjil().
This was error prone, moreover we need the get the proper exception when there is a real error in load_vidjil().

Now the check is on the file name ('.clntab'). There could be better strategies, but
the detection of the file type has to be separated from the parsing itself.
parent 17024651
......@@ -289,8 +289,14 @@ class ListWindows:
print "==>", output
with open(output, "w") as file:
json.dump(self, file, indent=2, default=self.toJson)
def load(self, file_path, pipeline, verbose=True):
def load(self, file_path, *args, **kwargs):
if not '.clntab' in file_path:
self.load_vidjil(file_path, *args, **kwargs)
self.load_clntab(file_path, *args, **kwargs)
def load_vidjil(self, file_path, pipeline, verbose=True):
'''init listWindows with data file
Detects and selects the parser according to the file extension.'''
......@@ -300,17 +306,11 @@ class ListWindows:
if verbose:
print "<==", file_path, "\t",
with open(file_path, "r") as file:
with open(file_path, "r") as file:
tmp = json.load(file, object_hook=self.toPython)
except Exception:
if pipeline:
# renaming, private pipeline
f = '/'.join(file_path.split('/')[2:-1])
......@@ -441,7 +441,7 @@ class ListWindows:
print "### Cut merged file, keeping window in the top %d for at least one point" % limit
return self
def load_clntab(self, file_path):
def load_clntab(self, file_path, *args, **kwargs):
'''Parser for .clntab file'''
self.d["vidjil_json_version"] = [VIDJIL_JSON_VERSION]
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