From 6c49217b0b2adac1e479422fcc56ae0a9e206d36 Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Wed, 20 Feb 2019 15:44:37 -0800 Subject: [PATCH] Make use of glob and os.path modules for filename handling --- packaging_scripts/pkgfiles.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packaging_scripts/pkgfiles.py b/packaging_scripts/pkgfiles.py index 58be57f..d767ea0 100644 --- a/packaging_scripts/pkgfiles.py +++ b/packaging_scripts/pkgfiles.py @@ -1,6 +1,8 @@ """Helper functions for dealing with package files.""" -import pathlib +import glob +import os +import os.path # ========== Constants ========== PKGEXT = 'pkg.tar.xz' @@ -18,20 +20,20 @@ def get_pkgfiles(query=None, directory=None, signatures_only=False): :param signatures_only: include only signature files :type signatures_only: bool :returns: paths of package files - :rtype: generator + :rtype: list """ if directory is not None: - path = pathlib.Path(directory) + path = directory else: - path = pathlib.Path.cwd() + path = os.getcwd() if signatures_only: if query is not None: - return path.glob(f"{query}*.{SIGEXT}") + return glob.glob(f"{path}/{query}*.{SIGEXT}") else: - return path.glob(f"*.{SIGEXT}") + return glob.glob(f"{path}/*.{SIGEXT}") else: if query is not None: - return path.glob(f"{query}*.{PKGEXT}") + return glob.glob(f"{path}/{query}*.{PKGEXT}") else: - return path.glob(f"*.{PKGEXT}") + return glob.glob(f"{path}/*.{PKGEXT}")