kitir/_libs/file_utils.py
def file_diff(file_a, file_b, output=None, **kwargs):
    """
    performance a diff between two files
    :param file_a: first file
    :param file_b: second file
    :param output: output file for diff
    :param kwargs: any kwargs
    :return:
    """
    filemode = kwargs.pop('filemode', 'Ur')
    if kwargs.pop('show_log', True):
        log.trace('performing file diff between two files: a={} b={}'.format(file_a, file_b))
    with open(file_a, mode=filemode) as af, open(file_b, mode=filemode) as bf:
        al = af.readlines()

        diff = list(difflib.unified_diff(
            al,
            bf.readlines(),
            fromfile=file_a,
            tofile=file_b,
            n=0
        ))

    if diff:
        if output:
            with open(output, 'w') as f:
                f.writelines(diff)
        if kwargs.pop('as_bool', True):
            return True
        return diff

    return False

    performance a diff between two files
    :param file_a: first file
    :param file_b: second file
    :param output: output file for diff
    :param kwargs: any kwargs
    :return:
    
performance a diff between two files
performance a diff between two files
def file_diff(file_a, file_b, output=None, **kwargs):
    filemode = kwargs.pop('filemode', 'Ur')
    if kwargs.pop('show_log', True):
        log.trace('performing file diff between two files: a={} b={}'.format(file_a, file_b))
    with open(file_a, mode=filemode) as af, open(file_b, mode=filemode) as bf:
        al = af.readlines()
        diff = list(difflib.unified_diff(
            al,
            bf.readlines(),
            fromfile=file_a,
            tofile=file_b,
            n=0
        ))
    if diff:
        if output:
            with open(output, 'w') as f:
                f.writelines(diff)
        if kwargs.pop('as_bool', True):
            return True
        return diff
    return False
def file_diff ( file_a , file_b , output = None , ** kwargs ) : filemode = kwargs . pop ( 'filemode' , 'Ur' ) if kwargs . pop ( 'show_log' , True ) : log . trace ( 'performing file diff between two files: a={} b={}' . format ( file_a , file_b ) ) with open ( file_a , mode = filemode ) as af , open ( file_b , mode = filemode ) as bf : al = af . readlines ( ) diff = list ( difflib . unified_diff ( al , bf . readlines ( ) , fromfile = file_a , tofile = file_b , n = 0 ) ) if diff : if output : with open ( output , 'w' ) as f : f . writelines ( diff ) if kwargs . pop ( 'as_bool' , True ) : return True return diff return False
performance a diff between two files
performance a diff between two files
"""
    performance a diff between two files
    :param file_a: first file
    :param file_b: second file
    :param output: output file for diff
    :param kwargs: any kwargs
    :return:
    """
None
file_a
None
file_b
None
output
output file for diff
output file for diff
kwargs
None