From 658ec65dcd4026f0a2836a6fef9bee75fac89c54 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Mon, 21 Mar 2011 16:34:31 +0300 Subject: [PATCH] Add reVerSplit to cl_utils and convert func. --- pym/cl_utils.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pym/cl_utils.py b/pym/cl_utils.py index b2ce3ce..d4d7ace 100644 --- a/pym/cl_utils.py +++ b/pym/cl_utils.py @@ -807,3 +807,21 @@ def getProgPath(progname): return progname else: return False + +reVerSplit = re.compile(r"^(.*?)-(([^-]+?)(?:-(r\d+))?)(?:.(tbz2))?$",re.S) +def reVerSplitToPV(x): + """Convert match from reVerSplit to PV hash""" + if x: + match = x.groups() + return {'PN':match[0], + 'PF':"%s-%s"%(match[0],match[1]), + 'P':"%s-%s"%(match[0],match[2]), + 'PV':match[2], + 'PR':match[3] or "r0", + 'PVR':match[1]} + return {'PN':"", + 'PF':"", + 'P':"", + 'PV':"", + 'PR':"", + 'PVR':""}.copy()