Commit 243bf3e4 authored by ssomnath's avatar ssomnath
Browse files

Far more robust is_valid_file functions for be_odf and gline

parent 7af22840
......@@ -67,6 +67,10 @@ class BEodfTranslator(Translator):
data_path = path.abspath(data_path)
if path.isfile(data_path):
ext = data_path.split('.')[-1]
if ext.lower() not in ['jpg', 'png', 'jpeg', 'tiff', 'mat', 'txt',
'dat', 'xls', 'xlsx']:
return None
# we only care about the folder names at this point...
data_path, _ = path.split(data_path)
......@@ -88,9 +92,23 @@ class BEodfTranslator(Translator):
if any([x.find('bigtime_0') > 0 and x.endswith('.dat') for x in path_dict.values()]):
# This is a G-mode Line experiment:
return None
if any([x in path_dict.keys() for x in ['parm_txt', 'old_mat_parms',
'read_real', 'read_imag']]):
return path_dict['parm_txt']
if any([x.find('bigtime_0') > 0 and x.endswith('.dat') for x in
path_dict.values()]):
# This is a G-mode Line experiment:
return None
parm_found = any([piece in path_dict.keys() for piece in
['parm_txt', 'old_mat_parms']])
real_found = any([piece in path_dict.keys() for piece in
['read_real', 'write_real']])
imag_found = any([piece in path_dict.keys() for piece in
['read_imag', 'write_imag']])
if parm_found and real_found and imag_found:
if 'parm_txt' in path_dict.keys():
return path_dict['parm_txt']
else:
return path_dict['old_mat_parms']
else:
return None
......
......@@ -51,7 +51,15 @@ class GLineTranslator(Translator):
data_path = path.abspath(data_path)
orig_path = None
if path.isfile(data_path):
ext = data_path.split('.')[-1]
if ext.lower() not in ['jpg', 'png', 'jpeg', 'tiff', 'mat', 'txt',
'dat', 'xls', 'xlsx']:
return None
# we only care about the folder names at this point...
orig_path = data_path
# Assume that the file is amongst all other data files
folder_path, _ = path.split(data_path)
else:
......@@ -60,6 +68,12 @@ class GLineTranslator(Translator):
data_path = path.join(folder_path, listdir(path=folder_path)[0])
basename, parm_paths, data_paths = GLineTranslator._parse_file_path(data_path)
# The provided file must either p
if orig_path is not None:
if not any([orig_path in sel_dict.values() for sel_dict in
[parm_paths, data_paths]]):
return None
if len(parm_paths) == 2 and len(data_paths) > 0:
return parm_paths['parm_txt']
......
Supports Markdown
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