From b33b15ae76c9f60c04648f4d01ecdc7b887f675b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 20 Mar 2017 11:05:04 +0100 Subject: [PATCH] doc: fix generate-setting-docs.py for supporting Python 3 sorted() style Python 3 has no "cmp" argument to sorted(). Fixes: b0da972f5fa51608cca5837af9fe7094818204f8 --- libnm/generate-setting-docs.py | 11 ++++------- 1 file 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)