allow disabling sort in get_files

This commit is contained in:
Dima Gerasimov 2020-01-04 18:19:13 +00:00
parent cf087ae316
commit 41167f5172

View file

@ -95,13 +95,16 @@ def setup_logger(logger, level=None, format=None, datefmt=None):
PathIsh = Union[Path, str] PathIsh = Union[Path, str]
def get_files(pp: PathIsh, glob: str) -> List[Path]: def get_files(pp: PathIsh, glob: str, sort=True) -> List[Path]:
""" """
Helper function to avoid boilerplate. Helper function to avoid boilerplate.
""" """
path = Path(pp) path = Path(pp)
if path.is_dir(): if path.is_dir():
return list(sorted(path.glob(glob))) gp: Iterable[Path] = path.glob(glob)
if sort:
gp = sorted(gp)
return list(gp)
else: else:
assert path.is_file(), path assert path.is_file(), path
# TODO FIXME assert matches glob?? # TODO FIXME assert matches glob??