aboutsummaryrefslogtreecommitdiff
path: root/factory/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'factory/utils.py')
-rw-r--r--factory/utils.py12
1 files changed, 1 insertions, 11 deletions
diff --git a/factory/utils.py b/factory/utils.py
index 2fcd7ff..ce72a9a 100644
--- a/factory/utils.py
+++ b/factory/utils.py
@@ -57,16 +57,6 @@ def extract_dict(prefix, kwargs, pop=True, exclude=()):
return extracted
-def declength_compare(a, b):
- """Compare objects, choosing longest first."""
- if len(a) > len(b):
- return -1
- elif len(a) < len(b):
- return 1
- else:
- return cmp(a, b)
-
-
def multi_extract_dict(prefixes, kwargs, pop=True, exclude=()):
"""Extracts all values from a given list of prefixes.
@@ -78,7 +68,7 @@ def multi_extract_dict(prefixes, kwargs, pop=True, exclude=()):
"""
results = {}
exclude = list(exclude)
- for prefix in sorted(prefixes, cmp=declength_compare):
+ for prefix in sorted(prefixes, key=lambda x: -len(x)):
extracted = extract_dict(prefix, kwargs, pop=pop, exclude=exclude)
results[prefix] = extracted
exclude.extend(