Cache pkg name list so we don't recreate the list for every package
This commit is contained in:
parent
10fd0f7073
commit
bc18c9dc78
1 changed files with 11 additions and 5 deletions
|
@ -235,21 +235,27 @@ def expand_pkgspec_from_fnmatches(m, pkgspec, cache):
|
||||||
if frozenset('*?[]!').intersection(pkgname_pattern):
|
if frozenset('*?[]!').intersection(pkgname_pattern):
|
||||||
if version:
|
if version:
|
||||||
m.fail_json(msg="pkgname wildcard and version can not be mixed")
|
m.fail_json(msg="pkgname wildcard and version can not be mixed")
|
||||||
|
|
||||||
# handle multiarch pkgnames, the idea is that "apt*" should
|
# handle multiarch pkgnames, the idea is that "apt*" should
|
||||||
# only select native packages. But "apt*:i386" should still work
|
# only select native packages. But "apt*:i386" should still work
|
||||||
if not ":" in pkgname_pattern:
|
if not ":" in pkgname_pattern:
|
||||||
matches = fnmatch.filter(
|
try:
|
||||||
[pkg.name for pkg in cache
|
pkg_name_cache = _non_multiarch
|
||||||
if not ":" in pkg.name], pkgname_pattern)
|
except NameError:
|
||||||
|
pkg_name_cache = _non_multiarch = [pkg.name for pkg in cache if not ':' in pkg.name]
|
||||||
else:
|
else:
|
||||||
matches = fnmatch.filter(
|
try:
|
||||||
[pkg.name for pkg in cache], pkgname_pattern)
|
pkg_name_cache = _all_pkg_names
|
||||||
|
except NameError:
|
||||||
|
pkg_name_cache = _all_pkg_names = [pkg.name for pkg in cache]
|
||||||
|
matches = fnmatch.filter(pkg_name_cache, pkgname_pattern)
|
||||||
|
|
||||||
if len(matches) == 0:
|
if len(matches) == 0:
|
||||||
m.fail_json(msg="No package(s) matching '%s' available" % str(pkgname_pattern))
|
m.fail_json(msg="No package(s) matching '%s' available" % str(pkgname_pattern))
|
||||||
else:
|
else:
|
||||||
new_pkgspec.extend(matches)
|
new_pkgspec.extend(matches)
|
||||||
else:
|
else:
|
||||||
|
# No wildcards in name
|
||||||
new_pkgspec.append(pkgspec_pattern)
|
new_pkgspec.append(pkgspec_pattern)
|
||||||
return new_pkgspec
|
return new_pkgspec
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue