Commit e2a7e2f8 authored by payno's avatar payno
Browse files

[edfscan] add an ignore paramter to skip some pattern

parent f9aa8251
Pipeline #21722 failed with stages
in 55 seconds
......@@ -453,7 +453,7 @@ class EDFTomoScan(TomoScanBase):
@staticmethod
def get_refs_url(scan_path: str, prefix: str='refHST',
file_ext: str='.edf') -> dict:
file_ext: str='.edf', ignore=None) -> dict:
"""
:param scan_path:
......@@ -469,6 +469,7 @@ class EDFTomoScan(TomoScanBase):
_logger.error(scan_path + ' is not a directory. Cannot extract '
'RefHST files')
return res
def get_next_free_index(key, keys):
"""return next free key from keys by converting it to a string
with `key_value (n)` after it
......@@ -480,8 +481,17 @@ class EDFTomoScan(TomoScanBase):
index += 1
return new_key
def ignore_file(file_name, to_ignore):
if to_ignore is None:
return False
for pattern in to_ignore:
if pattern in file_name:
return True
return False
for file_ in os.listdir(scan_path):
if file_.startswith(prefix) and file_.endswith(file_ext):
if (file_.startswith(prefix) and file_.endswith(file_ext)
and not ignore_file(file_, ignore)):
index = EDFTomoScan.guess_index_frm_file_name(_file=file_,
basename=os.path.basename(scan_path))
file_fp = os.path.join(scan_path, file_)
......
......@@ -223,6 +223,11 @@ class TestOriDarksFlats(unittest.TestCase):
ref_urls = (self.scan.get_refs_url(prefix='refHST', scan_path=self.scan.path))
self.assertEqual(len(ref_urls), 2)
ref_urls = (self.scan.get_refs_url(prefix='ref',
scan_path=self.scan.path,
ignore=('HST',)))
self.assertEqual(len(ref_urls), 40)
def testDarksOri(self):
darks = self.scan.get_darks_url(prefix='darkend',
scan_path=self.scan.path)
......
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