summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Maas <opensource@till.name>2014-05-24 09:37:51 +0200
committerTill Maas <opensource@till.name>2014-05-24 09:37:51 +0200
commit5f5c69d93397ab771a2d6e995462628fa909d5ab (patch)
tree7610356b1c3887385441b3f1a86d9a7ce0beef8e
parent8b9a07cf91d330b92eb59d8dde6ccb5b3f486078 (diff)
downloadcnucnu-5f5c69d93397ab771a2d6e995462628fa909d5ab.tar.gz
cnucnu-5f5c69d93397ab771a2d6e995462628fa909d5ab.tar.xz
cnucnu-5f5c69d93397ab771a2d6e995462628fa909d5ab.zip
Speed up PackageList()HEADmaster
-rwxr-xr-xcnucnu/package_list.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/cnucnu/package_list.py b/cnucnu/package_list.py
index c211de2..bf8e41f 100755
--- a/cnucnu/package_list.py
+++ b/cnucnu/package_list.py
@@ -334,10 +334,15 @@ class PackageList:
page_text, package_line_regex,
"== List Of Packages ==", "<!-- END LIST OF PACKAGES -->"):
(name, regex, url) = package_data
- matched_names = fnmatch.filter(repo.nvr_dict.keys(), name)
- if len(matched_names) == 0:
- # Add non-matching name to trigger an error/warning later
- # FIXME: Properly report bad names
+ # fnmatch.filter() is very slow, therefore check first if any
+ # wildcard chars exist
+ if "*" in name or "?" in name or "[" in name:
+ matched_names = fnmatch.filter(repo.nvr_dict.keys(), name)
+ if len(matched_names) == 0:
+ # Add non-matching name to trigger an error/warning
+ # later FIXME: Properly report bad names
+ matched_names = [name]
+ else:
matched_names = [name]
for name in matched_names:
packages.append(