@@ -150,21 +150,23 @@ def file(self, path, outpath=None):
150
150
151
151
Use :func:`inplace` to tidy files in-place.
152
152
"""
153
- with self ._get_writer (outpath ) as writer :
153
+ with self ._get_output (outpath ) as writer :
154
154
self ._tidy (get_model (path ), writer )
155
155
if not outpath :
156
156
return writer .getvalue ().replace ('\r \n ' , '\n ' )
157
157
158
- def _get_writer (self , outpath ):
159
- return file_writer (outpath , newline = '' , usage = 'Tidy output' )
158
+ def _get_output (self , path ):
159
+ return file_writer (path , newline = '' , usage = 'Tidy output' )
160
160
161
161
def inplace (self , * paths ):
162
162
"""Tidy file(s) in-place.
163
163
164
164
:param paths: Paths of the files to to process.
165
165
"""
166
166
for path in paths :
167
- self ._tidy (get_model (path ), output = self ._get_writer (path ))
167
+ model = get_model (path )
168
+ with self ._get_output (path ) as output :
169
+ self ._tidy (model , output )
168
170
169
171
def directory (self , path ):
170
172
"""Tidy a directory.
@@ -176,7 +178,7 @@ def directory(self, path):
176
178
data = SuiteStructureBuilder ().build ([path ])
177
179
data .visit (self )
178
180
179
- def _tidy (self , model , output = None ):
181
+ def _tidy (self , model , output ):
180
182
Cleaner ().visit (model )
181
183
NewlineCleaner (self .line_separator ,
182
184
self .short_test_name_length ).visit (model )
0 commit comments