Skip to content

Commit

Permalink
Clarify documentation for non-numbered input files
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminhwilliams committed Oct 14, 2020
1 parent f7c99ab commit e0a879f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions screen19/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def prettyprint_procrunner(d):
)


def make_template(f):
def make_template(f): # type: (str) -> (str, int)
"""
Generate a xia2-style filename template.
Expand All @@ -104,17 +104,22 @@ def make_template(f):
before the file extension.
For example, the filename example_01_0001.cbf becomes example_01_####.cbf.
If the input data are in a single file and its name doesn't match the above
template, the resulting filename template is simply the input file name and the
resultant image number is None.
This might be the case for input data in NeXus NXmx HDF5 format, for example,
where one typically passes a file with a name like example_master.h5.
:param f: Filename, with extension.
:type f: str
:return: Filename template, with extension; image number.
:rtype: Tuple(str, int)
"""
# Split the file from its path
directory, f = os.path.split(f)
# Split off the file extension, assuming it begins at the first full stop,
# also split the last contiguous group of digits off the filename root
try:
root, number, extension = re.split(r"([0-9#]+)(?=\.\w)", f, 1)
# Catch the case where the input data file name doesn't match the numbered pattern.
except ValueError:
template = f
image = None
Expand Down

0 comments on commit e0a879f

Please sign in to comment.