merge default doc-dc
authorDamien Correia
Thu, 14 Jun 2018 10:41:06 +0200
branchdoc-dc
changeset 265 1284a943f979
parent 264 6a4a802b91a3 (current diff)
parent 194 9313b3c435eb (diff)
child 266 b63d9050929d
merge default
--- a/src/pyams_utils/adapter.py	Wed Jun 13 11:39:04 2018 +0200
+++ b/src/pyams_utils/adapter.py	Thu Jun 14 10:41:06 2018 +0200
@@ -170,3 +170,12 @@
             if callback:
                 callback(adapter)
     return adapter
+
+
+def get_adapter_weight(item):
+    """Get adapters weight sort key"""
+    name, adapter = item
+    try:
+        return int(adapter.weight), name
+    except (TypeError, AttributeError):
+        return 0, name