diff options
author | Michael Weiss <dev.primeos@gmail.com> | 2020-09-10 12:01:01 +0200 |
---|---|---|
committer | Michael Weiss <dev.primeos@gmail.com> | 2020-09-10 12:30:03 +0200 |
commit | ceb3acfa8b67ca1c4b255da7db96af972ccbe64e (patch) | |
tree | c93d4703374742dfdd82707a02e97b87e49249e3 /pkgs/applications/networking | |
parent | ae0221e4d00107d7afc8fae96d25590835c1913c (diff) |
chromium: update.py: Keep the channel order consistent
This makes Git diffs way easier to read. Using sort_keys=True is usually better but with this implementation the output is a bit nicer to read IMO.
Diffstat (limited to 'pkgs/applications/networking')
-rwxr-xr-x | pkgs/applications/networking/browsers/chromium/update.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/pkgs/applications/networking/browsers/chromium/update.py b/pkgs/applications/networking/browsers/chromium/update.py index 0a0d512004b54..bfc7f0d2478c3 100755 --- a/pkgs/applications/networking/browsers/chromium/update.py +++ b/pkgs/applications/networking/browsers/chromium/update.py @@ -4,9 +4,11 @@ import csv import json import subprocess +import sys + from codecs import iterdecode +from collections import OrderedDict from os.path import abspath, dirname -from sys import stderr from urllib.request import urlopen HISTORY_URL = 'https://omahaproxy.appspot.com/history?os=linux' @@ -27,7 +29,7 @@ def nix_prefetch_url(url, algo='sha256'): channels = {} last_channels = load_json(JSON_PATH) -print(f'GET {HISTORY_URL}', file=stderr) +print(f'GET {HISTORY_URL}', file=sys.stderr) with urlopen(HISTORY_URL) as resp: builds = csv.DictReader(iterdecode(resp, 'utf-8')) for build in builds: @@ -59,5 +61,17 @@ with urlopen(HISTORY_URL) as resp: channels[channel_name] = channel with open(JSON_PATH, 'w') as out: - json.dump(channels, out, indent=2) + def get_channel_key(item): + channel_name = item[0] + if channel_name == 'stable': + return 0 + elif channel_name == 'beta': + return 1 + elif channel_name == 'dev': + return 2 + else: + print(f'Error: Unexpected channel: {channel_name}', file=sys.stderr) + sys.exit(1) + sorted_channels = OrderedDict(sorted(channels.items(), key=get_channel_key)) + json.dump(sorted_channels, out, indent=2) out.write('\n') |