summaryrefslogtreecommitdiffstats
path: root/pym/portage_versions.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-01-11 22:21:07 +0000
committerZac Medico <zmedico@gentoo.org>2007-01-11 22:21:07 +0000
commit4c93236b70445b62f9f1286ed2a7414a7b46e679 (patch)
tree9d1865f0a576ea3a4893accdfcc0a30ae9525779 /pym/portage_versions.py
parentdd3317e5ad453622ad2d121e565c35589202112f (diff)
downloadportage-4c93236b70445b62f9f1286ed2a7414a7b46e679.tar.gz
portage-4c93236b70445b62f9f1286ed2a7414a7b46e679.tar.bz2
portage-4c93236b70445b62f9f1286ed2a7414a7b46e679.zip
Use a global to ensure that the valid_category regex is cached.
svn path=/main/trunk/; revision=5574
Diffstat (limited to 'pym/portage_versions.py')
-rw-r--r--pym/portage_versions.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/pym/portage_versions.py b/pym/portage_versions.py
index 715319167..dffcdd3b1 100644
--- a/pym/portage_versions.py
+++ b/pym/portage_versions.py
@@ -248,6 +248,8 @@ def pkgsplit(mypkg,silent=1):
pkgcache[mypkg]=None
return None
+_valid_category = re.compile("^\w[\w-]*")
+
catcache={}
def catpkgsplit(mydata,silent=1):
"""
@@ -267,7 +269,7 @@ def catpkgsplit(mydata,silent=1):
"""
# Categories may contain a-zA-z0-9+_- but cannot start with -
- valid_category = re.compile("^\w[\w-]*")
+ global _valid_category
try:
if not catcache[mydata]:
return None
@@ -280,7 +282,7 @@ def catpkgsplit(mydata,silent=1):
retval=["null"]
p_split=pkgsplit(mydata,silent=silent)
elif len(mysplit)==2:
- if not valid_category.match(mysplit[0]):
+ if not _valid_category.match(mysplit[0]):
raise InvalidData("Invalid category in %s" %mydata )
retval=[mysplit[0]]
p_split=pkgsplit(mysplit[1],silent=silent)