author | Thierry Florac <thierry.florac@onf.fr> |
Thu, 14 Jun 2018 08:58:27 +0200 | |
changeset 194 | 9313b3c435eb |
parent 193 | 59bd282a06f8 |
child 195 | 65b6d930b42b |
child 265 | 1284a943f979 |
--- 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