Show More
@@ -228,6 +228,12 b' def replacetokens(tokens, opts):' | |||||
228 | yield adjusttokenpos(t._replace(string=fn[4:]), coloffset) |
|
228 | yield adjusttokenpos(t._replace(string=fn[4:]), coloffset) | |
229 | continue |
|
229 | continue | |
230 |
|
230 | |||
|
231 | if t.type == token.NAME and t.string in opts['treat-as-kwargs']: | |||
|
232 | if _isitemaccess(i): | |||
|
233 | _ensuresysstr(i + 2) | |||
|
234 | if _ismethodcall(i, 'get', 'pop', 'setdefault', 'popitem'): | |||
|
235 | _ensuresysstr(i + 4) | |||
|
236 | ||||
231 | # Looks like "if __name__ == '__main__'". |
|
237 | # Looks like "if __name__ == '__main__'". | |
232 | if (t.type == token.NAME and t.string == '__name__' |
|
238 | if (t.type == token.NAME and t.string == '__name__' | |
233 | and _isop(i + 1, '==')): |
|
239 | and _isop(i + 1, '==')): | |
@@ -270,10 +276,15 b' def main():' | |||||
270 | help='edit files in place') |
|
276 | help='edit files in place') | |
271 | ap.add_argument('--dictiter', action='store_true', default=False, |
|
277 | ap.add_argument('--dictiter', action='store_true', default=False, | |
272 | help='rewrite iteritems() and itervalues()'), |
|
278 | help='rewrite iteritems() and itervalues()'), | |
|
279 | ap.add_argument('--treat-as-kwargs', nargs="+", | |||
|
280 | help="ignore kwargs-like objects"), | |||
273 | ap.add_argument('files', metavar='FILE', nargs='+', help='source file') |
|
281 | ap.add_argument('files', metavar='FILE', nargs='+', help='source file') | |
274 | args = ap.parse_args() |
|
282 | args = ap.parse_args() | |
275 | opts = { |
|
283 | opts = { | |
276 | 'dictiter': args.dictiter, |
|
284 | 'dictiter': args.dictiter, | |
|
285 | 'treat-as-kwargs': set( | |||
|
286 | args.treat_as_kwargs | |||
|
287 | ) if args.treat_as_kwargs else set() | |||
277 | } |
|
288 | } | |
278 | for fname in args.files: |
|
289 | for fname in args.files: | |
279 | if args.inplace: |
|
290 | if args.inplace: |
General Comments 0
You need to be logged in to leave comments.
Login now