Clean up if statements for get_pkgfiles()

This commit is contained in:
Eric Torres 2019-01-29 14:33:51 -08:00
parent 574415b3d8
commit 64b2e6c747

View File

@ -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}")