Files
@ 7b58d01e925a
Branch filter:
Location: kallithea/scripts/source_format.py - annotation
7b58d01e925a
701 B
text/x-python
pytype: add assertion to guide pytype through Whoosh usage
Mute pytype warnings:
File "kallithea/controllers/admin/admin.py", line 105, in _journal_filter: No attribute 'fieldname' on None [attribute-error]
In Optional[Any]
File "kallithea/controllers/admin/admin.py", line 106, in _journal_filter: No attribute 'text' on None [attribute-error]
In Optional[Any]
File "kallithea/controllers/admin/admin.py", line 107, in _journal_filter: No attribute 'startdate' on None [attribute-error]
In Optional[Any]
File "kallithea/controllers/admin/admin.py", line 107, in _journal_filter: No attribute 'enddate' on None [attribute-error]
In Optional[Any]
Mute pytype warnings:
File "kallithea/controllers/admin/admin.py", line 105, in _journal_filter: No attribute 'fieldname' on None [attribute-error]
In Optional[Any]
File "kallithea/controllers/admin/admin.py", line 106, in _journal_filter: No attribute 'text' on None [attribute-error]
In Optional[Any]
File "kallithea/controllers/admin/admin.py", line 107, in _journal_filter: No attribute 'startdate' on None [attribute-error]
In Optional[Any]
File "kallithea/controllers/admin/admin.py", line 107, in _journal_filter: No attribute 'enddate' on None [attribute-error]
In Optional[Any]
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)
|