From 64b2e6c747b3d6d3c39fbbb92a7ba6b2ec6ba539 Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Tue, 29 Jan 2019 14:33:51 -0800 Subject: [PATCH] Clean up if statements for get_pkgfiles() --- packaging_scripts/pkgfiles.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packaging_scripts/pkgfiles.py b/packaging_scripts/pkgfiles.py index bc101ec..58be57f 100644 --- a/packaging_scripts/pkgfiles.py +++ b/packaging_scripts/pkgfiles.py @@ -6,8 +6,9 @@ import pathlib PKGEXT = 'pkg.tar.xz' SIGEXT = f"{PKGEXT}.sig" + # ========== Functions ========== -def get_pkgfiles(query='', directory=None, signatures_only=False): +def get_pkgfiles(query=None, directory=None, signatures_only=False): """Return a list of package files in the current working directory. :param query: names of package files to search for @@ -17,7 +18,7 @@ def get_pkgfiles(query='', directory=None, signatures_only=False): :param signatures_only: include only signature files :type signatures_only: bool :returns: paths of package files - :rtype: list + :rtype: generator """ if directory is not None: path = pathlib.Path(directory) @@ -25,6 +26,12 @@ def get_pkgfiles(query='', directory=None, signatures_only=False): path = pathlib.Path.cwd() if signatures_only: - return list(path.glob(f"{query}*.{SIGEXT}")) - - return list(path.glob(f"{query}*.{PKGEXT}")) + if query is not None: + return path.glob(f"{query}*.{SIGEXT}") + else: + return path.glob(f"*.{SIGEXT}") + else: + if query is not None: + return path.glob(f"{query}*.{PKGEXT}") + else: + return path.glob(f"*.{PKGEXT}")