Skip to content
Snippets Groups Projects
Commit 8b4ca564 authored by Hahn, Steven's avatar Hahn, Steven Committed by GitHub
Browse files

Merge pull request #20189 from mantidproject/20185_eqsans_file_extension

Extension is now a list of accepted formats
parents e0b92cef b9e3efe8
No related merge requests found
...@@ -177,7 +177,7 @@ class DataCatalog(object): ...@@ -177,7 +177,7 @@ class DataCatalog(object):
""" """
Data catalog Data catalog
""" """
extension = "nxs" extension = ["nxs"]
data_set_cls = DataSet data_set_cls = DataSet
def __init__(self, replace_db=True): def __init__(self, replace_db=True):
...@@ -275,22 +275,22 @@ class DataCatalog(object): ...@@ -275,22 +275,22 @@ class DataCatalog(object):
try: try:
for f in os.listdir(data_dir): for f in os.listdir(data_dir):
if f.endswith(self.extension): for extension in self.extension:
file_path = os.path.join(data_dir, f) if f.endswith(extension):
file_path = os.path.join(data_dir, f)
if hasattr(self.data_set_cls, "find_with_api"): if hasattr(self.data_set_cls, "find_with_api"):
d = self.data_set_cls.find_with_api(file_path, c, d = self.data_set_cls.find_with_api(file_path, c,
process_files=process_files) process_files=process_files)
else: else:
d = self.data_set_cls.find(file_path, c, d = self.data_set_cls.find(file_path, c,
process_files=process_files) process_files=process_files)
if d is not None: if d is not None:
if call_back is not None: if call_back is not None:
attr_list = d.as_string_list() attr_list = d.as_string_list()
type_id = self.data_set_cls.data_type_cls.get_likely_type(d.id, c) type_id = self.data_set_cls.data_type_cls.get_likely_type(d.id, c)
attr_list += (type_id,) attr_list += (type_id,)
call_back(attr_list) call_back(attr_list)
self.catalog.append(d) self.catalog.append(d)
self.db.commit() self.db.commit()
c.close() c.close()
......
...@@ -52,9 +52,12 @@ class EQSANSDataSet(DataSet): ...@@ -52,9 +52,12 @@ class EQSANSDataSet(DataSet):
def handle(cls, file_path): def handle(cls, file_path):
""" """
Return a DB handle for the given file, such as a run number Return a DB handle for the given file, such as a run number
This will handle file formats in two formats:
EQSANS_([0-9]+)_event
EQSANS_([0-9]+).nxs
""" """
file_path = file_path.strip() file_path = file_path.strip()
r_re = re.search("EQSANS_([0-9]+)_event", file_path) r_re = re.search("EQSANS_([0-9]+)(_event|\.nxs)", file_path)
if r_re is not None: if r_re is not None:
return r_re.group(1) return r_re.group(1)
else: else:
...@@ -112,7 +115,7 @@ class EQSANSDataSet(DataSet): ...@@ -112,7 +115,7 @@ class EQSANSDataSet(DataSet):
class DataCatalog(BaseCatalog): class DataCatalog(BaseCatalog):
extension = "nxs" extension = ["nxs", "nxs.h5"]
data_set_cls = EQSANSDataSet data_set_cls = EQSANSDataSet
def __init__(self, replace_db=False): def __init__(self, replace_db=False):
......
...@@ -94,7 +94,7 @@ class HFIRDataSet(DataSet): ...@@ -94,7 +94,7 @@ class HFIRDataSet(DataSet):
class DataCatalog(BaseCatalog): class DataCatalog(BaseCatalog):
extension = "xml" extension = ["xml"]
data_set_cls = HFIRDataSet data_set_cls = HFIRDataSet
def __init__(self, replace_db=False): def __init__(self, replace_db=False):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment