From c789f779ef03e7025fa159f744c77b20517de518 Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Wed, 20 Feb 2019 15:49:18 -0800 Subject: [PATCH] Clean if statement block and globs --- packaging_scripts/pkgfiles.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/packaging_scripts/pkgfiles.py b/packaging_scripts/pkgfiles.py index d767ea0..56e0935 100644 --- a/packaging_scripts/pkgfiles.py +++ b/packaging_scripts/pkgfiles.py @@ -16,7 +16,7 @@ def get_pkgfiles(query=None, directory=None, signatures_only=False): :param query: names of package files to search for :type query: str :param directory: a directory to search in - :type directory: str, bytes, or path-like object + :type directory: str :param signatures_only: include only signature files :type signatures_only: bool :returns: paths of package files @@ -27,13 +27,11 @@ def get_pkgfiles(query=None, directory=None, signatures_only=False): else: path = os.getcwd() - if signatures_only: - if query is not None: - return glob.glob(f"{path}/{query}*.{SIGEXT}") - else: - return glob.glob(f"{path}/*.{SIGEXT}") - else: - if query is not None: - return glob.glob(f"{path}/{query}*.{PKGEXT}") - else: - return glob.glob(f"{path}/*.{PKGEXT}") + if signatures_only and query is not None: + return glob.glob(f"{path}/*{query}*.{SIGEXT}") + elif signatures_only and query is None: + return glob.glob(f"{path}/*.{SIGEXT}") + elif not signatures_only and query is not None: + return glob.glob(f"{path}/*{query}*.{PKGEXT}") + elif not signatures_only and query is None: + return glob.glob(f"{path}/*.{PKGEXT}")