From 41167f5172d121fe0e6148297939bc5f69dd7c35 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Sat, 4 Jan 2020 18:19:13 +0000 Subject: [PATCH] allow disabling sort in get_files --- my/common.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/my/common.py b/my/common.py index c9b70fb..bb90b63 100644 --- a/my/common.py +++ b/my/common.py @@ -95,13 +95,16 @@ def setup_logger(logger, level=None, format=None, datefmt=None): 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. """ path = Path(pp) 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: assert path.is_file(), path # TODO FIXME assert matches glob??