diff --git a/release.py b/release.py index 686a1a113fa02b43da1965e5483eb4420a19d425..01771ea44e163bfceaad4282a7ac0cb1b604cd41 100755 --- a/release.py +++ b/release.py @@ -1,10 +1,11 @@ -#!/usr/bin/python -from __future__ import print_function +#!/usr/bin/env python3 import argparse +import configparser import os import re import sys +import datetime from subprocess import check_call, check_output from weboob.tools.misc import to_unicode @@ -47,8 +48,38 @@ def make_tarball(tag, wheel): print('To upload to PyPI, run: twine upload -s %s' % ' '.join(files)) +def changed_modules(changes, changetype): + for change in changes: + change = change.decode('utf-8').split() + if change[0] == changetype: + m = re.match(r'modules/([^/]+)/__init__\.py', change[1]) + if m: + yield m.group(1) + + +def get_caps(module, config): + try: + return sorted(c for c in config[module]['capabilities'].split() if c != 'CapCollection') + except KeyError: + return ['**** FILL ME **** (running weboob update could help)'] + +def new_modules(start, end): + #os.chdir(os.path.dirname(__file__)) + modules_info = configparser.ConfigParser() + with open('modules/modules.list') as f: + modules_info.read_file(f) + git_cmd = ['git', 'diff', '--no-renames', '--name-status', '%s..%s' % (start, end), '--', 'modules/'] + + added_modules = sorted(changed_modules(check_output(git_cmd).splitlines(), 'A')) + deleted_modules = sorted(changed_modules(check_output(git_cmd).splitlines(), 'D')) + + for added_module in added_modules: + yield 'New %s module (%s)' % (added_module, ', '.join(get_caps(added_module, modules_info))) + for deleted_module in deleted_modules: + yield 'Deleted %s module' % deleted_module + + def changelog(start, end='HEAD'): - # TODO new modules, deleted modules def sortkey(d): """Put the commits with multiple domains at the end""" return (len(d), d) @@ -58,6 +89,9 @@ def sortkey(d): title, domains = commitinfo(commithash) commits.setdefault(domains, []).append(title) + for line in new_modules(start, end): + commits.setdefault(('General',), []).append(line) + cl = '' for domains in sorted(commits.keys(), key=sortkey): cl += '\n\n\t' + '\n\t'.join(domains) @@ -85,8 +119,6 @@ def domain(path): return 'Browser: Filters' except IndexError: return 'Browser' - elif dirs[1] == 'deprecated': - return 'Old Browser' elif dirs[1] == 'applications': try: return 'Applications: {}'.format(dirs[2]) @@ -112,7 +144,7 @@ def domain(path): def commitinfo(commithash): - info = check_output(['git', 'show', '--format=%s', '--name-only', commithash]).splitlines() + info = check_output(['git', 'show', '--format=%s', '--name-only', commithash]).decode('utf-8').splitlines() title = to_unicode(info[0]) domains = set([domain(p) for p in info[2:] if domain(p)]) if 'Unknown' in domains and len(domains) > 1: @@ -122,7 +154,7 @@ def commitinfo(commithash): if 'Unknown' not in domains: # When the domains are known, hide the title prefixes - title = re.sub('^(?:[\w\./\s]+:|\[[\w\./\s]+\])\s*', '', title, flags=re.UNICODE) + title = re.sub(r'^(?:[\w\./\s]+:|\[[\w\./\s]+\])\s*', '', title, flags=re.UNICODE) return title, tuple(sorted(domains)) @@ -132,11 +164,12 @@ def previous_version(): Get the highest version tag """ for v in check_output(['git', 'tag', '-l', '*.*', '--sort=-v:refname']).splitlines(): - return v + return v.decode() def prepare(start, end, version): - print(changelog(start, end).encode('utf-8')) + print('Weboob %s (%s)\n' % (version, datetime.date.today().strftime('%Y-%m-%d'))) + print(changelog(start, end)) if __name__ == '__main__': diff --git a/release.sh b/release.sh index c58f37ba1900c2b4bd5be44a6ee6699e1af42340..fa94c0711e2ca564a6221b42b660f39e2996228c 100755 --- a/release.sh +++ b/release.sh @@ -19,9 +19,8 @@ echo "Generating ChangeLog..." export LANG=en_US.utf8 mv ChangeLog ChangeLog.old -echo -e "Weboob $VERSION (`date +%Y-%m-%d`)\n" > ChangeLog -python release.py prepare $VERSION >> ChangeLog -echo -e "\n\n" >> ChangeLog +./release.py prepare $VERSION > ChangeLog +echo -e "\n" >> ChangeLog cat ChangeLog.old >> ChangeLog rm -f ChangeLog.old @@ -47,7 +46,7 @@ echo "Release tag:" git tag $VERSION -s -m "Weboob $VERSION" echo -ne "\n" -python release.py tarball $VERSION +./release.py tarball $VERSION echo -ne "\nDo you want to change the version number (y/n) " read change_version diff --git a/tools/newsince.py b/tools/newsince.py deleted file mode 100755 index 1290a4f0ff5a47f15e1810d9385113cca642afb4..0000000000000000000000000000000000000000 --- a/tools/newsince.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python3 -import os -import re -import subprocess -import sys - -import configparser - -since = sys.argv[1] - - -def changed_modules(changes, changetype): - for change in changes: - change = change.decode('utf-8').split() - if change[0] == changetype: - m = re.match('modules/([^/]+)/__init__\.py', change[1]) - if m: - yield m.group(1) - - -def get_caps(module, config): - try: - return sorted(c for c in config[module]['capabilities'].split() if c != 'CapCollection') - except KeyError: - return ['**** FILL ME **** (running weboob update could help)'] - -os.chdir(os.path.join(os.path.dirname(__file__), os.path.pardir)) -modules_info = configparser.ConfigParser() -with open('modules/modules.list') as f: - modules_info.read_file(f) -git_cmd = ['git', 'diff', '--no-renames', '--name-status', '%s..HEAD' % since, '--', 'modules/'] - -added_modules = sorted(changed_modules(subprocess.check_output(git_cmd).splitlines(), 'A')) -deleted_modules = sorted(changed_modules(subprocess.check_output(git_cmd).splitlines(), 'D')) - -for added_module in added_modules: - print('        * New %s module (%s)' % (added_module, ', '.join(get_caps(added_module, modules_info)))) -for deleted_module in deleted_modules: - print('        * Deleted %s module' % deleted_module)