##// END OF EJS Templates
byteify-strings: add --treat-as-kwargs argument to handle kwargs-like objects...
Raphaël Gomès -
r42908:f95b59ff default
parent child Browse files
Show More
@@ -228,6 +228,12 b' def replacetokens(tokens, opts):'
228 228 yield adjusttokenpos(t._replace(string=fn[4:]), coloffset)
229 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 237 # Looks like "if __name__ == '__main__'".
232 238 if (t.type == token.NAME and t.string == '__name__'
233 239 and _isop(i + 1, '==')):
@@ -270,10 +276,15 b' def main():'
270 276 help='edit files in place')
271 277 ap.add_argument('--dictiter', action='store_true', default=False,
272 278 help='rewrite iteritems() and itervalues()'),
279 ap.add_argument('--treat-as-kwargs', nargs="+",
280 help="ignore kwargs-like objects"),
273 281 ap.add_argument('files', metavar='FILE', nargs='+', help='source file')
274 282 args = ap.parse_args()
275 283 opts = {
276 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 289 for fname in args.files:
279 290 if args.inplace:
General Comments 0
You need to be logged in to leave comments. Login now