diff options
author | Thomas Haller <thaller@redhat.com> | 2017-03-20 11:05:04 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-03-20 11:12:40 +0100 |
commit | b33b15ae76c9f60c04648f4d01ecdc7b887f675b (patch) | |
tree | 8abb08b239f4847ad8150c71f4a2306787440d05 | |
parent | b869d9cc0dda4fe5300f5ec5b5a090199ecd4e3e (diff) | |
download | NetworkManager-b33b15ae76c9f60c04648f4d01ecdc7b887f675b.tar.gz |
doc: fix generate-setting-docs.py for supporting Python 3 sorted() style
Python 3 has no "cmp" argument to sorted().
Fixes: b0da972f5fa51608cca5837af9fe7094818204f8
-rwxr-xr-x | libnm/generate-setting-docs.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/libnm/generate-setting-docs.py b/libnm/generate-setting-docs.py index 86fe08cde1..d0625b01d7 100755 --- a/libnm/generate-setting-docs.py +++ b/libnm/generate-setting-docs.py @@ -162,13 +162,10 @@ def get_default_value(setting, pspec, propxml): return default_value -def cmp_settings(x,y): +def settings_sort_key(x): x_prefix = x.attrib['{%s}symbol-prefix' % ns_map['c']] - y_prefix = y.attrib['{%s}symbol-prefix' % ns_map['c']] - if x_prefix == "setting_connection": - # Always sort NMSettingConnection first - return -1; - return cmp(x_prefix, y_prefix) + # always sort NMSettingConnection first + return (x_prefix != "setting_connection", x_prefix); def escape(val): return str(val).replace('"', '"') @@ -194,7 +191,7 @@ settings = girxml.findall('./gi:namespace/gi:class[@parent="Setting"]', ns_map) # Hack. Need a better way to do this ipxml = girxml.find('./gi:namespace/gi:class[@name="SettingIPConfig"]', ns_map) settings.extend(girxml.findall('./gi:namespace/gi:class[@parent="SettingIPConfig"]', ns_map)) -settings = sorted(settings, cmp=cmp_settings) +settings = sorted(settings, key=settings_sort_key) init_constants(girxml, settings) |