Clean if statement block and globs

This commit is contained in:
Eric Torres 2019-02-20 15:49:18 -08:00
parent 6c49217b0b
commit c789f779ef

View File

@ -16,7 +16,7 @@ def get_pkgfiles(query=None, directory=None, signatures_only=False):
:param query: names of package files to search for :param query: names of package files to search for
:type query: str :type query: str
:param directory: a directory to search in :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 :param signatures_only: include only signature files
:type signatures_only: bool :type signatures_only: bool
:returns: paths of package files :returns: paths of package files
@ -27,13 +27,11 @@ def get_pkgfiles(query=None, directory=None, signatures_only=False):
else: else:
path = os.getcwd() path = os.getcwd()
if signatures_only: if signatures_only and query is not None:
if query is not None: return glob.glob(f"{path}/*{query}*.{SIGEXT}")
return glob.glob(f"{path}/{query}*.{SIGEXT}") elif signatures_only and query is None:
else: return glob.glob(f"{path}/*.{SIGEXT}")
return glob.glob(f"{path}/*.{SIGEXT}") elif not signatures_only and query is not None:
else: return glob.glob(f"{path}/*{query}*.{PKGEXT}")
if query is not None: elif not signatures_only and query is None:
return glob.glob(f"{path}/{query}*.{PKGEXT}") return glob.glob(f"{path}/*.{PKGEXT}")
else:
return glob.glob(f"{path}/*.{PKGEXT}")