Merged revisions 70656,70668-70669,70671,70701,70703,70706 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70656 | georg.brandl | 2009-03-28 14:33:33 -0500 (Sat, 28 Mar 2009) | 2 lines
Add a script to fixup rst files if the pre-commit hook rejects them.
........
r70668 | benjamin.peterson | 2009-03-28 22:16:57 -0500 (Sat, 28 Mar 2009) | 1 line
a more realistic example
........
r70669 | benjamin.peterson | 2009-03-28 22:31:40 -0500 (Sat, 28 Mar 2009) | 1 line
stop the versionchanged directive from hiding the docs
........
r70671 | benjamin.peterson | 2009-03-28 22:39:58 -0500 (Sat, 28 Mar 2009) | 1 line
fix consistency
........
r70701 | benjamin.peterson | 2009-03-29 17:27:26 -0500 (Sun, 29 Mar 2009) | 1 line
add missing import
........
r70703 | benjamin.peterson | 2009-03-29 21:14:21 -0500 (Sun, 29 Mar 2009) | 1 line
fix import
........
r70706 | benjamin.peterson | 2009-03-30 09:42:23 -0500 (Mon, 30 Mar 2009) | 1 line
add missing import
........
2009-03-30 12:04:16 -03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
# Make a reST file compliant to our pre-commit hook.
|
|
|
|
# Currently just remove trailing whitespace.
|
|
|
|
|
2009-03-31 19:46:50 -03:00
|
|
|
|
Merged revisions 70656,70668-70669,70671,70701,70703,70706 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70656 | georg.brandl | 2009-03-28 14:33:33 -0500 (Sat, 28 Mar 2009) | 2 lines
Add a script to fixup rst files if the pre-commit hook rejects them.
........
r70668 | benjamin.peterson | 2009-03-28 22:16:57 -0500 (Sat, 28 Mar 2009) | 1 line
a more realistic example
........
r70669 | benjamin.peterson | 2009-03-28 22:31:40 -0500 (Sat, 28 Mar 2009) | 1 line
stop the versionchanged directive from hiding the docs
........
r70671 | benjamin.peterson | 2009-03-28 22:39:58 -0500 (Sat, 28 Mar 2009) | 1 line
fix consistency
........
r70701 | benjamin.peterson | 2009-03-29 17:27:26 -0500 (Sun, 29 Mar 2009) | 1 line
add missing import
........
r70703 | benjamin.peterson | 2009-03-29 21:14:21 -0500 (Sun, 29 Mar 2009) | 1 line
fix import
........
r70706 | benjamin.peterson | 2009-03-30 09:42:23 -0500 (Mon, 30 Mar 2009) | 1 line
add missing import
........
2009-03-30 12:04:16 -03:00
|
|
|
import sys, re, shutil
|
|
|
|
|
|
|
|
ws_re = re.compile(r'\s+(\r?\n)$')
|
|
|
|
|
|
|
|
def main(argv=sys.argv):
|
|
|
|
rv = 0
|
|
|
|
for filename in argv[1:]:
|
|
|
|
try:
|
|
|
|
with open(filename, 'rb') as f:
|
|
|
|
lines = f.readlines()
|
|
|
|
new_lines = [ws_re.sub(r'\1', line) for line in lines]
|
|
|
|
if new_lines != lines:
|
2009-03-31 19:46:50 -03:00
|
|
|
print('Fixing %s...' % filename)
|
Merged revisions 70656,70668-70669,70671,70701,70703,70706 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70656 | georg.brandl | 2009-03-28 14:33:33 -0500 (Sat, 28 Mar 2009) | 2 lines
Add a script to fixup rst files if the pre-commit hook rejects them.
........
r70668 | benjamin.peterson | 2009-03-28 22:16:57 -0500 (Sat, 28 Mar 2009) | 1 line
a more realistic example
........
r70669 | benjamin.peterson | 2009-03-28 22:31:40 -0500 (Sat, 28 Mar 2009) | 1 line
stop the versionchanged directive from hiding the docs
........
r70671 | benjamin.peterson | 2009-03-28 22:39:58 -0500 (Sat, 28 Mar 2009) | 1 line
fix consistency
........
r70701 | benjamin.peterson | 2009-03-29 17:27:26 -0500 (Sun, 29 Mar 2009) | 1 line
add missing import
........
r70703 | benjamin.peterson | 2009-03-29 21:14:21 -0500 (Sun, 29 Mar 2009) | 1 line
fix import
........
r70706 | benjamin.peterson | 2009-03-30 09:42:23 -0500 (Mon, 30 Mar 2009) | 1 line
add missing import
........
2009-03-30 12:04:16 -03:00
|
|
|
shutil.copyfile(filename, filename + '.bak')
|
|
|
|
with open(filename, 'wb') as f:
|
|
|
|
f.writelines(new_lines)
|
2009-03-31 19:46:50 -03:00
|
|
|
except Exception as err:
|
|
|
|
print('Cannot fix %s: %s' % (filename, err))
|
Merged revisions 70656,70668-70669,70671,70701,70703,70706 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70656 | georg.brandl | 2009-03-28 14:33:33 -0500 (Sat, 28 Mar 2009) | 2 lines
Add a script to fixup rst files if the pre-commit hook rejects them.
........
r70668 | benjamin.peterson | 2009-03-28 22:16:57 -0500 (Sat, 28 Mar 2009) | 1 line
a more realistic example
........
r70669 | benjamin.peterson | 2009-03-28 22:31:40 -0500 (Sat, 28 Mar 2009) | 1 line
stop the versionchanged directive from hiding the docs
........
r70671 | benjamin.peterson | 2009-03-28 22:39:58 -0500 (Sat, 28 Mar 2009) | 1 line
fix consistency
........
r70701 | benjamin.peterson | 2009-03-29 17:27:26 -0500 (Sun, 29 Mar 2009) | 1 line
add missing import
........
r70703 | benjamin.peterson | 2009-03-29 21:14:21 -0500 (Sun, 29 Mar 2009) | 1 line
fix import
........
r70706 | benjamin.peterson | 2009-03-30 09:42:23 -0500 (Mon, 30 Mar 2009) | 1 line
add missing import
........
2009-03-30 12:04:16 -03:00
|
|
|
rv = 1
|
|
|
|
return rv
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main())
|