noredink-ui/script/deprecated-modules-csv.py

43 lines
1.1 KiB
Python
Raw Normal View History

#!/usr/bin/env python
import csv
import json
2020-11-22 14:54:59 +03:00
import os.path as path
import re
import sys
2020-11-22 14:54:59 +03:00
HERE = path.realpath(path.abspath(path.join(path.dirname(__file__), '..')))
with open(path.join(HERE, 'elm.json'), 'r') as fh:
modules = json.load(fh)["exposed-modules"]
widgets = {}
for module in modules:
match = re.match(r'^(.+)\.V(\d+)$', module)
if match is None:
continue
widget, current_version = match.groups()
current_version = int(current_version)
if widget in widgets:
highest_version, rest = widgets[widget]
if current_version > highest_version:
rest.append(highest_version)
widgets[widget] = (current_version, rest)
else:
rest.append(current_version)
else:
widgets[widget] = (current_version, [])
writer = csv.writer(sys.stdout)
for (widget, (latest, deprecated)) in widgets.items():
for version in deprecated:
writer.writerow((
'{}.V{}'.format(widget, version),
'upgrade to V{}'.format(latest),
))
sys.stdout.close()