Changeset - c519638e5021
[Not reviewed]
default
0 1 0
timeless@gmail.com - 10 years ago 2016-05-03 14:10:06
timeless@gmail.com
spelling: probably
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/verlib.py
Show inline comments
 
@@ -230,49 +230,49 @@ def suggest_normalized_version(s):
 
    :returns: A rational version string, or None, if couldn't determine one.
 
    """
 
    try:
 
        NormalizedVersion(s)
 
        return s   # already rational
 
    except IrrationalVersionError:
 
        pass
 

	
 
    rs = s.lower()
 

	
 
    # part of this could use maketrans
 
    for orig, repl in (('-alpha', 'a'), ('-beta', 'b'), ('alpha', 'a'),
 
                       ('beta', 'b'), ('rc', 'c'), ('-final', ''),
 
                       ('-pre', 'c'),
 
                       ('-release', ''), ('.release', ''), ('-stable', ''),
 
                       ('+', '.'), ('_', '.'), (' ', ''), ('.final', ''),
 
                       ('final', '')):
 
        rs = rs.replace(orig, repl)
 

	
 
    # if something ends with dev or pre, we add a 0
 
    rs = re.sub(r"pre$", r"pre0", rs)
 
    rs = re.sub(r"dev$", r"dev0", rs)
 

	
 
    # if we have something like "b-2" or "a.2" at the end of the
 
    # version, that is pobably beta, alpha, etc
 
    # version, that is probably beta, alpha, etc
 
    # let's remove the dash or dot
 
    rs = re.sub(r"([abc|rc])[\-\.](\d+)$", r"\1\2", rs)
 

	
 
    # 1.0-dev-r371 -> 1.0.dev371
 
    # 0.1-dev-r79 -> 0.1.dev79
 
    rs = re.sub(r"[\-\.](dev)[\-\.]?r?(\d+)$", r".\1\2", rs)
 

	
 
    # Clean: 2.0.a.3, 2.0.b1, 0.9.0~c1
 
    rs = re.sub(r"[.~]?([abc])\.?", r"\1", rs)
 

	
 
    # Clean: v0.3, v1.0
 
    if rs.startswith('v'):
 
        rs = rs[1:]
 

	
 
    # Clean leading '0's on numbers.
 
    #TODO: unintended side-effect on, e.g., "2003.05.09"
 
    # PyPI stats: 77 (~2%) better
 
    rs = re.sub(r"\b0+(\d+)(?!\d)", r"\1", rs)
 

	
 
    # Clean a/b/c with no version. E.g. "1.0a" -> "1.0a0". Setuptools infers
 
    # zero.
 
    # PyPI stats: 245 (7.56%) better
 
    rs = re.sub(r"(\d+[abc])$", r"\g<1>0", rs)
 

	
0 comments (0 inline, 0 general)