Runs fix_file on each modified file.

        - Prints progress and diff depending on options.
        - Returns True if there were any changes
968378
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
470768
def reload_file(self, is_modified=True):
        

        if not foundations.common.path_exists(self.__file):
            raise foundations.exceptions.FileExistsError("{0} | '{1}' file doesn't exists!".format(
                self.__class__.__name__, self.__file))

        LOGGER.debug("> Reloading '{0}' file.".format(self.__file))
        reader = foundations.io.File(self.__file)
        if reader.cache():
            self.set_content(reader.content)
            self.set_file(self.__file, is_modified=is_modified)

            self.file_reloaded.emit()
            return True
188849
def on_change(modified, added, deleted)
      # Modifications and additions are treated the same.
      (modified + added).uniq.each do |path|
        if file = Ichiban::ProjectFile.from_abs(path)
          begin
            @loader.change(file) # Tell the Loader that this file has changed
            file.update
          rescue Exception => exc
            Ichiban.logger.exception(exc)
          end
        end
      end
      
      # Deletions are handled specially.
      deleted.each do |path|
        Ichiban::Deleter.new.delete_dest(path)
      end
      
      # Finally, propagate this change to any dependent files.
      (modified + added + deleted).uniq.each do |path|
        begin
          Ichiban::Dependencies.propagate(path)
        rescue => exc
          Ichiban.logger.exception(exc)
        end
      end
    end
381186
def changelog_modified?(*changelogs)
      changelogs = config.changelogs if changelogs.nil? || changelogs.empty?

      changelogs.any? { |changelog| git.modified_files.include?(changelog) }
    end
125482
def fix_config(self, options):
        
        options = super(FileOutputSink, self).fix_config(options)

        opt = "output"
        if opt not in options:
            options[opt] = "."
        if opt not in self.help:
            self.help[opt] = "The file to write to (string)."

        return options
290993
def apply_patch(diffs):
    
    pass

    if isinstance(diffs, patch.diff):
        diffs = [diffs]

    for diff in diffs:
        if diff.header.old_path == '/dev/null':
            text = []
        else:
            with open(diff.header.old_path) as f:
                text = f.read()

        new_text = apply_diff(diff, text)
        with open(diff.header.new_path, 'w') as f:
            f.write(new_text)
932299
function (data) {
          var isSigned = isTokenSigned(data.file);
          var isFinished = data.status === 'finished';
          var isComplete = isSigned && isFinished;
          debug('checking if run', url, 'is finished', isComplete);
          if (isComplete) {
            testRuns.removeListener('patched', checkIfRunIsFinished);
            resolve(data);
          }
        }
590461
def process_full_diff
        defaults = {
          :mode => '',
          :src => '',
          :dst => '',
          :type => 'modified'
        }
        final = {}
        current_file = nil
        if @full_diff.encoding.name != "UTF-8"
          full_diff_utf8_encoded = @full_diff.encode("UTF-8", "binary", { :invalid => :replace, :undef => :replace })
        else
          full_diff_utf8_encoded = @full_diff
        end
        full_diff_utf8_encoded.split("\n").each do |line|
          if m = /^diff --git a\/(.*?) b\/(.*?)/.match(line)
            current_file = m[1]
            final[current_file] = defaults.merge({:patch => line, :path => current_file})
          else
            if m = /^index (.......)\.\.(.......)( ......)*/.match(line)
              final[current_file][:src] = m[1]
              final[current_file][:dst] = m[2]
              final[current_file][:mode] = m[3].strip if m[3]
            end
            if m = /^([[:alpha:]]*?) file mode (......)/.match(line)
              final[current_file][:type] = m[1]
              final[current_file][:mode] = m[2]
            end
            if m = /^Binary files /.match(line)
              final[current_file][:binary] = true
            end
            final[current_file][:patch] << "\n" + line
          end
        end
        final.map { |e| [e[0], DiffFile.new(@base, e[1])] }
      end
945583
def extract_modified_lines(file_path, options)
      lines = Set.new

      flags = '--cached' if options[:staged]
      refs = options[:refs]
      subcmd = options[:subcmd] || 'diff'

      `git #{subcmd} --no-color --no-ext-diff -U0 #{flags} #{refs} -- "#{file_path}"`.
        scan(DIFF_HUNK_REGEX) do |start_line, lines_added|
        lines_added = (lines_added || 1).to_i # When blank, one line was added
        cur_line = start_line.to_i

        lines_added.times do
          lines.add cur_line
          cur_line += 1
        end
      end

      lines
    end
766450
def progress_patch(self, _=False):
        
        from .progress import ShellProgressView
        self.cli_ctx.progress_controller.init_progress(ShellProgressView())
        return self.cli_ctx.progress_controller
788375
def run_score(self):
        
        diffs = 0
        lines = 0
        for file in self.files:

            try:
                results = self._check(file)
            except Error as e:
                termcolor.cprint(e.msg, "yellow", file=sys.stderr)
                continue

            diffs += results.diffs
            lines += results.lines

        try:
            print(max(1 - diffs / lines, 0.0))
        except ZeroDivisionError:
            print(0.0)
1204675
def run_on_changes(paths)
      specs = Inspector.clean(paths)
      return false if specs.empty?

      specs += self.rerun_specs if options[:keep_failed]

      # RSpec reloads the files, so reload only non spec files
      (paths - specs).each { |path| Reloader.reload_file(path) }

      passed, failed_examples, passed_examples = Runner.run(specs, options)

      self.rerun_specs += failed_examples
      self.rerun_specs -= passed_examples

      run_all if passed && !self.last_run_passed && options[:all_after_pass]

      self.last_run_passed = passed

      throw :task_has_failed unless passed
    end
305651
def run_diff(self):
        
        files = tuple(self.files)
        # Use same header as more.
        header, footer = (termcolor.colored("{0}\n{{}}\n{0}\n".format(
            ":" * 14), "cyan"), "\n") if len(files) > 1 else ("", "")

        for file in files:
            print(header.format(file), end="")
            try:
                results = self._check(file)
            except Error as e:
                termcolor.cprint(e.msg, "yellow", file=sys.stderr)
                continue

            # Display results
            if results.diffs:
                print()
                print(*self.diff(results.original, results.styled), sep="\n")
                print()
                conjunction = "And"
            else:
                termcolor.cprint("Looks good!", "green")
                conjunction = "But"

            if results.diffs:
                for type, c in sorted(self._warn_chars):
                    color, verb = ("on_green", "insert") if type == "+" else ("on_red", "delete")
                    termcolor.cprint(c, None, color, end="")
                    termcolor.cprint(" means that you should {} a {}.".format(
                        verb, "newline" if c == "\\n" else "tab"), "yellow")

            if results.comment_ratio < results.COMMENT_MIN:
                termcolor.cprint("{} consider adding more comments!".format(conjunction), "yellow")

            if (results.comment_ratio < results.COMMENT_MIN or self._warn_chars) and results.diffs:
                print()
1281731
def update_progress(opts, progress, progress_iter, out):
    '''
    
    '''
    # Look up the outputter
    try:
        progress_outputter = salt.loader.outputters(opts)[out]
    except KeyError:  # Outputter is not loaded
        log.warning('Progress outputter not available.')
        return False
    progress_outputter(progress, progress_iter)
578083
def on_modified(self, event):
        
        logger.debug("file modified: %s", event.src_path)
        if not event.is_directory:
            self.update_file(event.src_path)
715233
def do_changed(self, subcmd, opts, component):
        

        releases = get_released_versions(component)
        latest = releases[0]

        filter_dir = components.comp_names[component].path

        latest_tag = '-'.join(latest)
        data = get_changed_since_tag(latest_tag, filter_dir)

        if len(data) > 0:
            print(data)
494647
def run_on_changes(paths)
      paths += @failed_paths if @options[:keep_failed]
      paths = @inspector.clean(paths).uniq

      if passed = @runner.run(paths)
        remove_failed(paths)

        # run all the specs if the run before this one failed
        if @last_failed && @options[:all_after_pass]
          @last_failed = false
          run_all
        end
      else
        @last_failed = true
        add_failed(paths)

        throw :task_has_failed
      end
    end