コード例 #1
0
def generate_diff(
    file_path1: str,
    file_path2: str,
    format_name: str = 'stylish',
) -> str:
    """Построение разницы содержимого двух файлов.

    Args:
        file_path1: путь до первого файла
        file_path2: путь до второго файла
        format_name: формат вывода

    Returns:
        отформатированный дифф
    """
    file1_data = get_file_data(file_path1)
    file2_data = get_file_data(file_path2)
    diff = make_diff(file1_data, file2_data)

    if format_name == 'plain':
        return plain.formatter(diff)
    elif format_name == 'json':
        return json_formatter.formatter(diff)
    return stylish.formatter(diff)
コード例 #2
0
def answer_json_nested(fixtures_path):
    return get_file_data(os.path.join(fixtures_path,
                                      'answer_json_nested.txt'), )
コード例 #3
0
def file2_plain_yaml(fixtures_path):
    return get_file_data(os.path.join(fixtures_path, 'file2.yaml'))
コード例 #4
0
def answer_stylish_plain_null_second(fixtures_path):
    return get_file_data(
        os.path.join(fixtures_path, 'answer_stylish_plain_null_second.txt'))
コード例 #5
0
def answer_stylish_plain_null_first(fixtures_path):
    return get_file_data(
        os.path.join(fixtures_path, 'answer_stylish_plain_null_first.txt'), )
コード例 #6
0
def file2_plain_json(fixtures_path):
    return get_file_data(os.path.join(fixtures_path, 'file2.json'))