mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Run 2to3 over new script.
This commit is contained in:
parent
369bc0f950
commit
17b9e27abe
1 changed files with 4 additions and 4 deletions
|
@ -3,7 +3,7 @@
|
||||||
# Make a reST file compliant to our pre-commit hook.
|
# Make a reST file compliant to our pre-commit hook.
|
||||||
# Currently just remove trailing whitespace.
|
# Currently just remove trailing whitespace.
|
||||||
|
|
||||||
from __future__ import with_statement
|
|
||||||
import sys, re, shutil
|
import sys, re, shutil
|
||||||
|
|
||||||
ws_re = re.compile(r'\s+(\r?\n)$')
|
ws_re = re.compile(r'\s+(\r?\n)$')
|
||||||
|
@ -16,12 +16,12 @@ def main(argv=sys.argv):
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
new_lines = [ws_re.sub(r'\1', line) for line in lines]
|
new_lines = [ws_re.sub(r'\1', line) for line in lines]
|
||||||
if new_lines != lines:
|
if new_lines != lines:
|
||||||
print 'Fixing %s...' % filename
|
print('Fixing %s...' % filename)
|
||||||
shutil.copyfile(filename, filename + '.bak')
|
shutil.copyfile(filename, filename + '.bak')
|
||||||
with open(filename, 'wb') as f:
|
with open(filename, 'wb') as f:
|
||||||
f.writelines(new_lines)
|
f.writelines(new_lines)
|
||||||
except Exception, err:
|
except Exception as err:
|
||||||
print 'Cannot fix %s: %s' % (filename, err)
|
print('Cannot fix %s: %s' % (filename, err))
|
||||||
rv = 1
|
rv = 1
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue