Skip to content

Commit

Permalink
Generalizes _get_all_iternums in order to handle compressed data (#77)
Browse files Browse the repository at this point in the history
* Generalizes _get_all_iternums in order to handle compressed data

* fix excessive line length

* Fixing style errors.
  • Loading branch information
apatlpo authored and rabernat committed Apr 6, 2018
1 parent 4b52181 commit f8ae6b3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions xmitgcm/mds_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,13 +749,16 @@ def _concat_dicts(list_of_dicts):
return result


def _get_all_iternums(data_dir, file_prefixes=None):
def _get_all_iternums(data_dir, file_prefixes=None,
file_format='*.??????????.data'):
"""Scan a directory for all iteration number suffixes."""
iternums = set()
all_datafiles = glob(os.path.join(data_dir, '*.??????????.data'))
all_datafiles = glob(os.path.join(data_dir, file_format))
istart = file_format.find('?')-len(file_format)
iend = file_format.rfind('?')-len(file_format)+1
for f in all_datafiles:
iternum = int(f[-15:-5])
prefix = os.path.split(f[:-16])[-1]
iternum = int(f[istart:iend])
prefix = os.path.split(f[:istart-1])[-1]
if file_prefixes is None:
iternums.add(iternum)
else:
Expand Down

0 comments on commit f8ae6b3

Please sign in to comment.