Update regexes and if statement

This commit is contained in:
Eric Torres 2019-03-25 16:59:49 -07:00
parent 7d3c9c7c38
commit bc55d14bfa

View File

@ -8,9 +8,9 @@ from pathlib import Path
# ========== Constants ========== # ========== Constants ==========
# Match any pkgfile of any name with the .pkg.tar.* extension # Match any pkgfile of any name with the .pkg.tar.* extension
PKGREGEX = r"^\w+[.]pkg[.]tar([.]\w+)?$" PKGREGEX = r"^[\w.+/-]+\.pkg\.tar(\.\w+)?$"
# Match any sigfile of any name with the .pkg.tar.*.sig extension # Match any sigfile of any name with the .pkg.tar.*.sig extension
SIGREGEX = r"^\w+[.]pkg[.]tar([.]\w+)?[.]sig$" SIGREGEX = r"^[\w.+/-]+\.pkg\.tar(\.\w+)?\.sig$"
# ========== Logging Setup =========== # ========== Logging Setup ===========
@ -30,7 +30,7 @@ def get(query=None, *, directory=None, signatures_only=False):
:yields: paths of package files :yields: paths of package files
""" """
path = Path.cwd() if directory is None else Path(directory) path = Path.cwd() if directory is None else Path(directory)
filequery = f"*{query}*" if query is not None else "*" filequery = f"*{query}*" if query else "*"
if signatures_only: if signatures_only:
yield from _filter_by_regex(filequery, SIGREGEX, path) yield from _filter_by_regex(filequery, SIGREGEX, path)