Anonymous avatar Anonymous committed 7e7d906

using a loop

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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.