changeset 194 | 9313b3c435eb |
parent 193 | 59bd282a06f8 |
child 196 | c0db0561ded3 |
--- a/src/pyams_utils/adapter.py Wed Jun 13 11:25:38 2018 +0200 +++ b/src/pyams_utils/adapter.py Thu Jun 14 08:58:27 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