def fix(self):
        """Runs fix_file on each modified file.

        - Prints progress and diff depending on options.
        - Returns True if there were any changes

        """
        from pep8radius.diff import print_diff, udiff_lines_fixed

        n = len(self.filenames_diff)
        _maybe_print('Applying autopep8 to touched lines in %s file(s).' % n)

        any_changes = False
        total_lines_changed = 0
        pep8_diffs = []
        for i, file_name in enumerate(self.filenames_diff, start=1):
            _maybe_print('%s/%s: %s: ' % (i, n, file_name), end='')
            _maybe_print('', min_=2)

            p_diff = self.fix_file(file_name)
            lines_changed = udiff_lines_fixed(p_diff) if p_diff else 0
            total_lines_changed += lines_changed

            if p_diff:
                any_changes = True
                if self.diff:
                    pep8_diffs.append(p_diff)

        if self.in_place:
            _maybe_print('pep8radius fixed %s lines in %s files.'
                         % (total_lines_changed, n),
                         verbose=self.verbose)
        else:
            _maybe_print('pep8radius would fix %s lines in %s files.'
                         % (total_lines_changed, n),
                         verbose=self.verbose)

        if self.diff:
            for diff in pep8_diffs:
                print_diff(diff, color=self.color)

        return any_changes
def fix ( self ) : from pep8radius . diff import print_diff , udiff_lines_fixed n = len ( self . filenames_diff ) _maybe_print ( 'Applying autopep8 to touched lines in %s file(s).' % n ) any_changes = False total_lines_changed = 0 pep8_diffs = [ ] for i , file_name in enumerate ( self . filenames_diff , start = 1 ) : _maybe_print ( '%s/%s: %s: ' % ( i , n , file_name ) , end = '' ) _maybe_print ( '' , min_ = 2 ) p_diff = self . fix_file ( file_name ) lines_changed = udiff_lines_fixed ( p_diff ) if p_diff else 0 total_lines_changed += lines_changed if p_diff : any_changes = True if self . diff : pep8_diffs . append ( p_diff ) if self . in_place : _maybe_print ( 'pep8radius fixed %s lines in %s files.' % ( total_lines_changed , n ) , verbose = self . verbose ) else : _maybe_print ( 'pep8radius would fix %s lines in %s files.' % ( total_lines_changed , n ) , verbose = self . verbose ) if self . diff : for diff in pep8_diffs : print_diff ( diff , color = self . color ) return any_changes
Runs fix_file on each modified file.

        - Prints progress and diff depending on options.
        - Returns True if there were any changes