Skip to content

Commit

Permalink
add verbose print for 2to3 fixer (for #325)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hideo Hattori committed Oct 10, 2017
1 parent 7aaf921 commit dd87b51
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions autopep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,16 +1439,21 @@ def refactor(source, fixer_names, ignore=None, filename=''):
return new_text


def code_to_2to3(select, ignore):
def code_to_2to3(select, ignore, where='', verbose=False):
fixes = set()
for code, fix in CODE_TO_2TO3.items():
if code_match(code, select=select, ignore=ignore):
if verbose:
print('---> Applying {0} fix for {1}'.format(where,
code.upper()),
file=sys.stderr)
fixes |= set(fix)
return fixes


def fix_2to3(source,
aggressive=True, select=None, ignore=None, filename=''):
aggressive=True, select=None, ignore=None, filename='',
where='global', verbose=False):
"""Fix various deprecated code (via lib2to3)."""
if not aggressive:
return source
Expand All @@ -1458,7 +1463,9 @@ def fix_2to3(source,

return refactor(source,
code_to_2to3(select=select,
ignore=ignore),
ignore=ignore,
where=where,
verbose=verbose),
filename=filename)


Expand Down Expand Up @@ -3238,7 +3245,9 @@ def apply_global_fixes(source, options, where='global', filename=''):
aggressive=options.aggressive,
select=options.select,
ignore=options.ignore,
filename=filename)
filename=filename,
where=where,
verbose=options.verbose)

return source

Expand Down

0 comments on commit dd87b51

Please sign in to comment.