Commits

ta...@MacZiade  committed 7e7d906

using a loop

  • Participants
  • Parent commits 79d3dfa
  • Branches tarek-postdev

Comments (0)

Files changed (1)

     except IrrationalVersionError:
         pass
 
-    rs = (s
-        .lower()
-        .replace('-alpha', 'a')
-        .replace('-beta', 'b')
-        .replace('alpha', 'a')
-        .replace('beta', 'b')
-        .replace('rc', 'c')
-        .replace('-', '.')
-        .replace('+', '.')
-        .replace('_', '.')
-        .replace(' ', '')
-        # Clean: 0.2.final, 0.5.0final
-        .replace('.final', '')
-        .replace('final', '')
-        )
+    rs = s.lower()
+
+    # part of this could use maketrans
+    for orig, repl in (('-alpha', 'a'), ('-beta', 'b'), ('alpha', 'a'),
+                       ('beta', 'b'), ('rc', 'c'), ('-', '.'),
+                       ('+', '.'), ('_', '.'), (' ', ''), ('.final', ''),
+                       ('final', '')):
+        rs = rs.replace(orig, repl)
 
     # Clean: 2.0.a.3, 2.0.b1, 0.9.0~c1
     rs = re.sub(r"[.~]?([abc])\.?", r"\1", rs)