diff options
author | cypherpunks <cypherpunks@torproject.org> | 2015-03-06 11:56:57 +0100 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-03-09 09:00:12 -0400 |
commit | 9dc90a5b7bf02bc9a034b57bdbc1588745d00447 (patch) | |
tree | 7f5f546f02b280f40bb1a4c0adc4974787d38227 /scripts | |
parent | 4ced3b59aad0fffd653869d486bb0f4b1c26b19f (diff) | |
download | tor-9dc90a5b7bf02bc9a034b57bdbc1588745d00447.tar.gz tor-9dc90a5b7bf02bc9a034b57bdbc1588745d00447.zip |
Add `check-changes` rule for checking formatting of changes files.
Additional fixes to make the change work;
- fix Python 2 vs 3 issues
- fix some PEP 8 warnings
- handle paths with numbers correctly
- mention the make rule in doc/HACKING.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/maint/lintChanges.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/scripts/maint/lintChanges.py b/scripts/maint/lintChanges.py index 69963aea28..19d03ec8da 100755 --- a/scripts/maint/lintChanges.py +++ b/scripts/maint/lintChanges.py @@ -1,19 +1,22 @@ #!/usr/bin/python +from __future__ import print_function +from __future__ import with_statement import sys import re - +import os def lintfile(fname): have_warned = [] + def warn(s): if not have_warned: have_warned.append(1) - print fname,":" - print "\t",s + print("{}:".format(fname)) + print("\t{}".format(s)) - m = re.search(r'(\d{3,})', fname) + m = re.search(r'(\d{3,})', os.path.basename(fname)) if m: bugnum = m.group(1) else: @@ -23,7 +26,7 @@ def lintfile(fname): contents = f.read() if bugnum and bugnum not in contents: - warn("bug number %s does not appear"%bugnum) + warn("bug number {} does not appear".format(bugnum)) lines = contents.split("\n") isBug = ("bug" in lines[0] or "fix" in lines[0]) @@ -44,11 +47,12 @@ def lintfile(fname): if re.search(r'[bB]ug (\d+)', contents): if not re.search(r'[Bb]ugfix on ', contents): warn("bugfix does not say 'bugfix on X.Y.Z'") - elif not re.search('[fF]ixes ([a-z ]*)bug (\d+); bugfix on ', contents): + elif not re.search('[fF]ixes ([a-z ]*)bug (\d+); bugfix on ', + contents): warn("bugfix incant is not semicoloned") -if __name__=='__main__': +if __name__ == '__main__': for fname in sys.argv[1:]: if fname.endswith("~"): continue |