Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions smithers/io/openfoam/openfoamhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ def _find_time_instants_subfolders(cls, path, fields_time_instants):
* `'first'`: same of `'all_numeric'`, but return only the folder whose
name is the smallest number of the set;
* `'not_first'`: same of `'all_numeric'`, but exclude the first folder;
* `'latestTime'`: same of `'all_numeric'`, but return only the folder
whose name is the largest number of the set;
* a list of folder names.
:type fields_time_instants: str or list
:returns: A list of tuples (first item: subfolder name, second item:
Expand All @@ -209,6 +211,7 @@ def is_numeric(x):
fields_time_instants == "all_numeric"
or fields_time_instants == "first"
or fields_time_instants == "not_first"
or fields_time_instants == "latestTime"
):
subfolders = next(os.walk(path))[1]
subfolders = list(filter(is_numeric, subfolders))
Expand All @@ -220,6 +223,8 @@ def is_numeric(x):
time_instant_subfolders = subfolders
elif fields_time_instants == "not_first":
time_instant_subfolders = sorted(subfolders)[1:]
elif fields_time_instants == "latestTime":
time_instant_subfolders = [sorted(subfolders)[-1]]
else:
# we want a list in order to return an iterable object
time_instant_subfolders = [sorted(subfolders)[0]]
Expand Down
Loading