cpython: 4feb889d3bed (original) (raw)
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -1075,6 +1075,7 @@ Tools/Demos
- Issue #10639: reindent.py no longer converts newlines and will raise an error if attempting to convert a file with mixed newlines.
--- a/Tools/scripts/reindent.py +++ b/Tools/scripts/reindent.py @@ -8,6 +8,8 @@ -r (--recurse) Recurse. Search for all .py files in subdirectories too. -n (--nobackup) No backup. Does not make a ".bak" file before reindenting. -v (--verbose) Verbose. Print informative msgs; else no output.
- (--newline) Newline. Specify the newline character to use (CRLF, LF).
Default is the same as the original file.[](#l2.8)
-h (--help) Help. Print this usage information and exit. Change Python (.py) files to use 4-space indents and no hard tab characters. @@ -65,10 +67,11 @@ def errprint(*args): def main(): import getopt
- global verbose, recurse, dryrun, makebackup, spec_newline
- spec_newline = None try: opts, args = getopt.getopt(sys.argv[1:], "drnvh",
["dryrun", "recurse", "nobackup", "verbose", "help"])[](#l2.21)
except getopt.error as msg: usage(msg) return["dryrun", "recurse", "nobackup", "verbose", "newline=", "help"])[](#l2.22)
@@ -81,6 +84,11 @@ def main(): makebackup = False elif o in ('-v', '--verbose'): verbose = True
elif o in ('--newline',):[](#l2.30)
if not a.upper() in ('CRLF', 'LF'):[](#l2.31)
usage()[](#l2.32)
return[](#l2.33)
spec_newline = dict(CRLF='\r\n', LF='\n')[a.upper()][](#l2.34) elif o in ('-h', '--help'):[](#l2.35) usage()[](#l2.36) return[](#l2.37)
@@ -118,9 +126,9 @@ def check(file): errprint("%s: I/O Error: %s" % (file, str(msg))) return
errprint("%s: mixed newlines detected; cannot process file" % file)[](#l2.45)
errprint("%s: mixed newlines detected; cannot continue without --newline" % file)[](#l2.46) return[](#l2.47)