diff options
| author | Nicolas <nick@zbm2.com> | 2020-12-21 11:01:10 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-21 11:01:10 +0000 |
| commit | 41c5d66cba9549c0187f39fabe5e68c4ac1954d4 (patch) | |
| tree | 68078a49ba4b4266be0b00cdedea7704bae9e9f6 /share | |
| parent | e1af65311e21aa9b1a7fc5d4df3f3040842b1db5 (diff) | |
| parent | c94a87b7bff3abbdc4fb0fc12454979556352c76 (diff) | |
| download | chirp-41c5d66cba9549c0187f39fabe5e68c4ac1954d4.tar.gz chirp-41c5d66cba9549c0187f39fabe5e68c4ac1954d4.tar.xz | |
Merge pull request #1 from mpoletiek/main
Upstream update
Diffstat (limited to 'share')
| -rwxr-xr-x | share/make_supported.py | 27 |
1 files changed, 25 insertions, 2 deletions
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) |
