<commit_before>import difflib

from coalib.results.Diff import Diff
from coalib.results.result_actions.ResultAction import ResultAction
from coalib.results.Result import Result


def print_beautified_diff(difflines):
    from coalib.output.ConsoleInteraction import format_line

    current_line_added = None
    current_line_subtracted = None
    for line in difflines:
        if line.startswith("@@"):
            values = line[line.find("-"):line.rfind(" ")]
            subtracted, added = tuple(values.split(" "))
            current_line_added = int(added.split(",")[0][1:])
            current_line_subtracted = int(subtracted.split(",")[0][1:])
        elif line.startswith("---"):
            print(format_line(line[4:], real_nr="----"))
        elif line.startswith("+++"):
            print(format_line(line[4:], mod_nr="++++"))
        elif line.startswith("+"):
            print(format_line(line[1:], mod_nr=current_line_added, symbol="+"))
            current_line_added += 1
        elif line.startswith("-"):
            print(format_line(line[1:],
                              real_nr=current_line_subtracted,
                              symbol="-"))
            current_line_subtracted += 1
        else:
            print(format_line(line[1:],
                              real_nr=current_line_subtracted,
                              mod_nr=current_line_added,
                              symbol=" "))
            current_line_subtracted += 1
            current_line_added += 1


class ShowPatchAction(ResultAction):
    @classmethod<commit_msg>ShowPatchAction: Inline format_line method<commit_after>import difflib

from coalib.results.Diff import Diff
from coalib.results.result_actions.ResultAction import ResultAction
from coalib.results.Result import Result


def format_line(line, real_nr="", sign="|", mod_nr="", symbol="", ):
    return "|{:>4}{}{:>4}|{:1}{}".format(real_nr,
                                         sign,
                                         mod_nr,
                                         symbol,
                                         line.rstrip("\n"))


def print_beautified_diff(difflines):
    current_line_added = None
    current_line_subtracted = None
    for line in difflines:
        if line.startswith("@@"):
            values = line[line.find("-"):line.rfind(" ")]
            subtracted, added = tuple(values.split(" "))
            current_line_added = int(added.split(",")[0][1:])
            current_line_subtracted = int(subtracted.split(",")[0][1:])
        elif line.startswith("---"):
            print(format_line(line[4:], real_nr="----"))
        elif line.startswith("+++"):
            print(format_line(line[4:], mod_nr="++++"))
        elif line.startswith("+"):
            print(format_line(line[1:], mod_nr=current_line_added, symbol="+"))
            current_line_added += 1
        elif line.startswith("-"):
            print(format_line(line[1:],
                              real_nr=current_line_subtracted,
                              symbol="-"))
            current_line_subtracted += 1
        else:
            print(format_line(line[1:],
                              real_nr=current_line_subtracted,
                              mod_nr=current_line_added,
                              symbol=" "))
            current_line_subtracted += 1
            current_line_added += 1


class ShowPatchAction(ResultAction):
    @classmethod
{'fraction_non_alphanumeric': 0.12895730467615452, 'fraction_numerical': 0.008422887017136218, 'mean_word_length': 1.9511568123393317, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6953127', 'n_tokens_mistral': 980, 'n_tokens_neox': 975, 'n_words': 156}