summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/reindent-rst.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-10-21 12:49:28 (GMT)
committerGeorg Brandl <georg@python.org>2010-10-21 12:49:28 (GMT)
commita9afb68789cdc2d8d3262afc2ffa209b5d8e224a (patch)
treef96d010bac97f838068291b4c0ef1f3de9bb0e50 /Tools/scripts/reindent-rst.py
parent50de5f56a9eba0e0da6fb48c22b85ee69daac105 (diff)
downloadcpython-a9afb68789cdc2d8d3262afc2ffa209b5d8e224a.zip
cpython-a9afb68789cdc2d8d3262afc2ffa209b5d8e224a.tar.gz
cpython-a9afb68789cdc2d8d3262afc2ffa209b5d8e224a.tar.bz2
#9095, #8912, #8999: add support in patchcheck for Mercurial checkouts, C file reindenting, and docs whitespace fixing.
Diffstat (limited to 'Tools/scripts/reindent-rst.py')
-rwxr-xr-xTools/scripts/reindent-rst.py21
1 files changed, 3 insertions, 18 deletions
diff --git a/Tools/scripts/reindent-rst.py b/Tools/scripts/reindent-rst.py
index a19406f..ceb84bf 100755
--- a/Tools/scripts/reindent-rst.py
+++ b/Tools/scripts/reindent-rst.py
@@ -3,27 +3,12 @@
# Make a reST file compliant to our pre-commit hook.
# Currently just remove trailing whitespace.
+import sys
-import sys, re, shutil
-
-ws_re = re.compile(br'\s+(\r?\n)$')
+import patchcheck
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(br'\1', line) for line in lines]
- if new_lines != lines:
- print('Fixing %s...' % filename)
- shutil.copyfile(filename, filename + '.bak')
- with open(filename, 'wb') as f:
- f.writelines(new_lines)
- except Exception as err:
- print('Cannot fix %s: %s' % (filename, err))
- rv = 1
- return rv
+ patchcheck.normalize_docs_whitespace(argv[1:])
if __name__ == '__main__':
sys.exit(main())