def refactor(source, fixer_names, ignore=None, filename=u''):
 from lib2to3 import pgen2
 try:
  new_text = refactor_with_2to3(source, fixer_names=fixer_names, filename=filename)
 except (pgen2.parse.ParseError, SyntaxError, UnicodeDecodeError, UnicodeEncodeError):
  return source
 if ignore:
  if ((ignore in new_text) and (ignore not in source)):
   return source
 return new_text

def refactor ( source , fixer_names , ignore = None , filename = u'' ) : from lib2to3 import pgen2 try : new_text = refactor_with_2to3 ( source , fixer_names = fixer_names , filename = filename ) except ( pgen2 . parse . ParseError , SyntaxError , UnicodeDecodeError , UnicodeEncodeError ) : return source if ignore : if ( ( ignore in new_text ) and ( ignore not in source ) ) : return source return new_text
return refactored code using lib2to3 .