Files @ 52dea05f8553
Branch filter:

Location: kallithea/scripts/source_format.py

Manuel Jacob
setup: bump maximum version of Mercurial to 7.0.x

The freeze for the Mercurial 7.0 release was done on February 28th. The release
of 7.0.0 was scheduled for March 1st, but was delayed. It is likely that the
release will happen soon without changes that would break Kallithea.

The tests pass and some quick manual testing of the web UI found no issues.
#!/usr/bin/env python3

# hg files 'set:!binary()&grep("^#!.*python")' 'set:**.py' | xargs scripts/source_format.py

import re
import sys


filenames = sys.argv[1:]

for fn in filenames:
    with open(fn) as f:
        org_content = f.read()

    mod_name = fn[:-3] if fn.endswith('.py') else fn
    mod_name = mod_name[:-9] if mod_name.endswith('/__init__') else mod_name
    mod_name = mod_name.replace('/', '.')
    def f(m):
        return '"""\n%s\n%s\n' % (mod_name, '~' * len(mod_name))
    new_content = re.sub(r'^"""\n(kallithea\..*\n)(~+\n)?', f, org_content, count=1, flags=re.MULTILINE)

    if new_content != org_content:
        with open(fn, 'w') as f:
            f.write(new_content)