2019-01-27 20:26:50 -08:00
|
|
|
"""Helper functions for dealing with package files."""
|
|
|
|
|
|
|
|
import pathlib
|
|
|
|
|
|
|
|
PKGEXT = 'pkg.tar.xz'
|
|
|
|
SIGEXT = f"{PKGEXT}.sig"
|
|
|
|
|
|
|
|
def get_pkgfiles(directory=None, signatures=False):
|
|
|
|
"""Return a list of package files in the current working directory.
|
|
|
|
|
|
|
|
:param directory: a directory to search in
|
|
|
|
:type directory: str, bytes, or path-like object
|
2019-01-28 08:08:23 -08:00
|
|
|
:param signatures: include only signature files
|
|
|
|
:type signatures: bool
|
2019-01-27 20:26:50 -08:00
|
|
|
:returns: paths of package files
|
|
|
|
:rtype: list
|
|
|
|
"""
|
2019-01-28 08:08:23 -08:00
|
|
|
if directory is not None:
|
2019-01-27 20:26:50 -08:00
|
|
|
path = pathlib.Path(directory)
|
|
|
|
else:
|
|
|
|
path = pathlib.Path.cwd()
|
|
|
|
|
|
|
|
if signatures:
|
|
|
|
return list(path.glob(f"*.{SIGEXT}"))
|
|
|
|
|
|
|
|
return list(path.glob(f"*.{PKGEXT}"))
|