(self, fixer_names, options=None, explicit=None)
Initializer.

        Args:
            fixer_names: a list of fixers to import
            options: a dict with configuration.
            explicit: a list of fixers to run even if they are explicit.
Initializer.
Initializer .
def __init__(self, fixer_names, options=None, explicit=None):
        """Initializer.

        Args:
            fixer_names: a list of fixers to import
            options: a dict with configuration.
            explicit: a list of fixers to run even if they are explicit.
        """
        self.fixers = fixer_names
        self.explicit = explicit or []
        self.options = self._default_options.copy()
        if options is not None:
            self.options.update(options)
        self.grammar = pygram.python_grammar.copy()

        if self.options['print_function']:
            del self.grammar.keywords["print"]
        elif self.options['exec_function']:
            del self.grammar.keywords["exec"]

        # When this is True, the refactor*() methods will call write_file() for
        # files processed even if they were not changed during refactoring. If
        # and only if the refactor method's write parameter was True.
        self.write_unchanged_files = self.options.get("write_unchanged_files")
        self.errors = []
        self.logger = logging.getLogger("RefactoringTool")
        self.fixer_log = []
        self.wrote = False
        self.driver = driver.Driver(self.grammar,
                                    convert=pytree.convert,
                                    logger=self.logger)
        self.pre_order, self.post_order = self.get_fixers()


        self.files = []  # List of files that were or should be modified

        self.BM = bm.BottomMatcher()
        self.bmi_pre_order = [] # Bottom Matcher incompatible fixers
        self.bmi_post_order = []

        for fixer in chain(self.post_order, self.pre_order):
            if fixer.BM_compatible:
                self.BM.add_fixer(fixer)
                # remove fixers that will be handled by the bottom-up
                # matcher
            elif fixer in self.pre_order:
                self.bmi_pre_order.append(fixer)
            elif fixer in self.post_order:
                self.bmi_post_order.append(fixer)

        self.bmi_pre_order_heads = _get_headnode_dict(self.bmi_pre_order)
        self.bmi_post_order_heads = _get_headnode_dict(self.bmi_post_order)
def __init__ ( self , fixer_names , options = None , explicit = None ) : self . fixers = fixer_names self . explicit = explicit or [ ] self . options = self . _default_options . copy ( ) if options is not None : self . options . update ( options ) self . grammar = pygram . python_grammar . copy ( ) if self . options [ 'print_function' ] : del self . grammar . keywords [ "print" ] elif self . options [ 'exec_function' ] : del self . grammar . keywords [ "exec" ] # When this is True, the refactor*() methods will call write_file() for # files processed even if they were not changed during refactoring. If # and only if the refactor method's write parameter was True. self . write_unchanged_files = self . options . get ( "write_unchanged_files" ) self . errors = [ ] self . logger = logging . getLogger ( "RefactoringTool" ) self . fixer_log = [ ] self . wrote = False self . driver = driver . Driver ( self . grammar , convert = pytree . convert , logger = self . logger ) self . pre_order , self . post_order = self . get_fixers ( ) self . files = [ ] # List of files that were or should be modified self . BM = bm . BottomMatcher ( ) self . bmi_pre_order = [ ] # Bottom Matcher incompatible fixers self . bmi_post_order = [ ] for fixer in chain ( self . post_order , self . pre_order ) : if fixer . BM_compatible : self . BM . add_fixer ( fixer ) # remove fixers that will be handled by the bottom-up # matcher elif fixer in self . pre_order : self . bmi_pre_order . append ( fixer ) elif fixer in self . post_order : self . bmi_post_order . append ( fixer ) self . bmi_pre_order_heads = _get_headnode_dict ( self . bmi_pre_order ) self . bmi_post_order_heads = _get_headnode_dict ( self . bmi_post_order )