From b74292b26cbf64bcb3b32032a3b09c19f9f82805 Mon Sep 17 00:00:00 2001 From: Matthew Poletiek Date: Sun, 20 Dec 2020 16:35:39 -0600 Subject: Fixing tests --- share/make_supported.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'share/make_supported.py') diff --git a/share/make_supported.py b/share/make_supported.py index 67ecebd..5934688 100755 --- a/share/make_supported.py +++ b/share/make_supported.py @@ -58,7 +58,7 @@ def supported_row(radio): try: value = ", ".join([str(x) for x in value if not str(x).startswith("?")]) - except Exception, e: + except Exception as e: raise if key == "memory_bounds": @@ -167,7 +167,30 @@ for radio in directory.DRV_TO_RADIO.values(): def get_key(rc): return '%s %s %s' % (rc.VENDOR, rc.MODEL, rc.VARIANT) -for radio in sorted(models, cmp=lambda a, b: get_key(a) < get_key(b) and -1 or 1): + + +# Python2 to 3 wrapper for converting an old comparison below to a key +def cmp_to_key(mycmp): + 'Convert a cmp= function into a key= function' + class K: + def __init__(self, obj, *args): + self.obj = obj + def __lt__(self, other): + return mycmp(self.obj, other.obj) < 0 + def __gt__(self, other): + return mycmp(self.obj, other.obj) > 0 + def __eq__(self, other): + return mycmp(self.obj, other.obj) == 0 + def __le__(self, other): + return mycmp(self.obj, other.obj) <= 0 + def __ge__(self, other): + return mycmp(self.obj, other.obj) >= 0 + def __ne__(self, other): + return mycmp(self.obj, other.obj) != 0 + return K + + +for radio in sorted(models, key=cmp_to_key(lambda a, b: get_key(a) < get_key(b) and -1 or 1)): if counter % 10 == 0: output(header_row()) _radio = radio(None) -- cgit v1.2.3