Changeset 391 for python/trunk/Tools/scripts/reindent.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Tools/scripts/reindent.py
r2 r391 36 36 The backup file is a copy of the one that is being reindented. The ".bak" 37 37 file is generated with shutil.copy(), but some corner cases regarding 38 user/group and permissions could leave the backup file more readable tha t38 user/group and permissions could leave the backup file more readable than 39 39 you'd prefer. You can always use the --nobackup option to prevent this. 40 40 """ … … 45 45 import os, shutil 46 46 import sys 47 import io 47 48 48 49 verbose = 0 … … 109 110 print "checking", file, "...", 110 111 try: 111 f = open(file)112 f = io.open(file) 112 113 except IOError, msg: 113 114 errprint("%s: I/O Error: %s" % (file, str(msg))) … … 116 117 r = Reindenter(f) 117 118 f.close() 119 120 newline = r.newlines 121 if isinstance(newline, tuple): 122 errprint("%s: mixed newlines detected; cannot process file" % file) 123 return 124 118 125 if r.run(): 119 126 if verbose: … … 127 134 if verbose: 128 135 print "backed up", file, "to", bak 129 f = open(file, "w")136 f = io.open(file, "w", newline=newline) 130 137 r.write(f) 131 138 f.close() … … 173 180 # indeed, they're our headache! 174 181 self.stats = [] 182 183 # Save the newlines found in the file so they can be used to 184 # create output without mutating the newlines. 185 self.newlines = f.newlines 175 186 176 187 def run(self):
Note:
See TracChangeset
for help on using the changeset viewer.