summaryrefslogtreecommitdiffstats
path: root/jenkins_jobs/alphanum.py
diff options
context:
space:
mode:
Diffstat (limited to 'jenkins_jobs/alphanum.py')
-rwxr-xr-xjenkins_jobs/alphanum.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/jenkins_jobs/alphanum.py b/jenkins_jobs/alphanum.py
index 7eb44bfc..6d2f9673 100755
--- a/jenkins_jobs/alphanum.py
+++ b/jenkins_jobs/alphanum.py
@@ -42,9 +42,9 @@ def getchunk(item):
# Subtract the matched portion from the original string
# if there was a match, otherwise set it to ""
- item = (item[itemchunk.end():] if itemchunk else "")
+ item = item[itemchunk.end() :] if itemchunk else ""
# Don't return the match object, just the text
- itemchunk = (itemchunk.group() if itemchunk else "")
+ itemchunk = itemchunk.group() if itemchunk else ""
return (itemchunk, item)
@@ -54,28 +54,28 @@ def cmp(a, b):
def alphanum(a, b):
- a = a.name if hasattr(a, 'name') else str(a)
- b = b.name if hasattr(b, 'name') else str(b)
+ a = a.name if hasattr(a, "name") else str(a)
+ b = b.name if hasattr(b, "name") else str(b)
n = 0
- while (n == 0):
+ while n == 0:
# Get a chunk and the original string with the chunk subtracted
(ac, a) = getchunk(a)
(bc, b) = getchunk(b)
# Both items contain only letters
- if (re_letters.match(ac) and re_letters.match(bc)):
+ if re_letters.match(ac) and re_letters.match(bc):
n = cmp(ac, bc)
else:
# Both items contain only numbers
- if (re_numbers.match(ac) and re_numbers.match(bc)):
+ if re_numbers.match(ac) and re_numbers.match(bc):
n = cmp(int(ac), int(bc))
# item has letters and one item has numbers, or one item is empty
else:
n = cmp(ac, bc)
# Prevent deadlocks
- if (n == 0):
+ if n == 0:
n = 1
return n
@@ -105,5 +105,5 @@ class AlphanumSort(object):
if __name__ == "__main__":
- mylist = ['a2', 'a1', 'a10', 'a']
- assert sorted(mylist, key=AlphanumSort) == ['a', 'a1', 'a2', 'a10']
+ mylist = ["a2", "a1", "a10", "a"]
+ assert sorted(mylist, key=AlphanumSort) == ["a", "a1", "a2", "a10"]