Files
@ f2dc57c123cf
Branch filter:
Location: kallithea/scripts/source_format.py - annotation
f2dc57c123cf
701 B
text/x-python
repo: introduce enable_downloads and enable_statistics when creating repos
These booleans were not shown in the normal repo creation form, so the form
validation applied the "default" values of False. These values were however not
used by the model when creating repos - it just unconditionally used the real
global defaults.
The API already exposed some of this, but it wasn't implemented.
The web form for creating repos lacked these fields, but it was present in the
repo edit form. Just make these fields mandatory. There will thus not be any
defaults to apply in the model for creating repos.
These booleans were not shown in the normal repo creation form, so the form
validation applied the "default" values of False. These values were however not
used by the model when creating repos - it just unconditionally used the real
global defaults.
The API already exposed some of this, but it wasn't implemented.
The web form for creating repos lacked these fields, but it was present in the
repo edit form. Just make these fields mandatory. There will thus not be any
defaults to apply in the model for creating repos.
f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e f8971422795e | #!/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)
|