summaryrefslogtreecommitdiffstats
path: root/cnucnu/helper.py
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2011-04-04 00:04:40 +0300
committerTill Maas <opensource@till.name>2011-04-14 17:22:50 +0200
commit4fe1d04ea38ca543932b9c33dc5b2ea4310aa480 (patch)
tree803eb36f0b193dc8127f8f6967ae5332476eea2e /cnucnu/helper.py
parent246222f7d118ad2cb4d06b0a5e8ddb677c0b43c0 (diff)
downloadcnucnu-4fe1d04ea38ca543932b9c33dc5b2ea4310aa480.tar.gz
cnucnu-4fe1d04ea38ca543932b9c33dc5b2ea4310aa480.tar.xz
cnucnu-4fe1d04ea38ca543932b9c33dc5b2ea4310aa480.zip
Compile RC regexps only once.
Diffstat (limited to 'cnucnu/helper.py')
-rw-r--r--cnucnu/helper.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/cnucnu/helper.py b/cnucnu/helper.py
index 81bdb5f..20be23f 100644
--- a/cnucnu/helper.py
+++ b/cnucnu/helper.py
@@ -168,12 +168,13 @@ def upstream_cmp(v1, v2):
else:
return diff
+__rc_ups_regex = re.compile("([^-rp]*)(-?(([Rr][Cc]|[Pp][Rr][Ee])[0-9]?))?")
+__rc_rel_regex = re.compile(r'0\.[0-9]*\.(([Rr][Cc]|[Pp][Rr][Ee])[0-9])')
+
def split_rc(version):
""" Split version into version and release candidate string if possible
"""
- import re
- RC = re.compile("([^-rp]*)(-?(([Rr][Cc]|[Pp][Rr][Ee])[0-9]?))?")
- match = RC.match(version)
+ match = __rc_ups_regex.match(version)
v = match.groups()[0]
rc = match.groups()[2]
@@ -186,9 +187,7 @@ def split_rc(version):
return (version, "")
def get_rc(release):
- import re
- RC = re.compile(r'0\.[0-9]*\.(([Rr][Cc]|[Pp][Rr][Ee])[0-9])')
- match = RC.match(release)
+ match = __rc_rel_regex.match(release)
if match:
rc = match.groups()[0]