How to use icdiff - 10 common examples

To help you get started, we’ve selected a few icdiff examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lab11 / eagle / scripts / eagle_bom_helper.py View on Github external
handle_orphan_parts(orphan_parts)

    if rows_before == rows:
        termcolor.cprint('No changes', attrs=['bold'])
        print(dataprint.to_string(rows))
    else:
        with tempfile.NamedTemporaryFile(mode='w+t') as before, tempfile.NamedTemporaryFile(mode='w+t') as after:
            # HACK for space of MPN entry on diff
            rows_before[0][rows_before[0].index('MPN')] = '.' * 8 + 'MPN' + '.' * 8
            rows[0][rows[0].index('MPN')] = '.' * 8 + 'MPN' + '.' * 8

            dataprint.to_file(before, rows_before)
            dataprint.to_file(after, rows)
            before.flush()
            after.flush()
            options = icdiff.get_options()[0]
            options.no_headers = True
            icdiff.diff_files(options, before.name, after.name)
    print('')

print()
r = input('Write updated Eagle files? [Y/n] ')
if len(r) and r[0].lower() == 'n':
    sys.exit()

sch.write(sch_file)
brd.write(brd_file)


###############################################################################
## Try to reduce the Eagle file diff churn a little
github lab11 / eagle / scripts / eagle_bom_helper.py View on Github external
if rows_before == rows:
        termcolor.cprint('No changes', attrs=['bold'])
        print(dataprint.to_string(rows))
    else:
        with tempfile.NamedTemporaryFile(mode='w+t') as before, tempfile.NamedTemporaryFile(mode='w+t') as after:
            # HACK for space of MPN entry on diff
            rows_before[0][rows_before[0].index('MPN')] = '.' * 8 + 'MPN' + '.' * 8
            rows[0][rows[0].index('MPN')] = '.' * 8 + 'MPN' + '.' * 8

            dataprint.to_file(before, rows_before)
            dataprint.to_file(after, rows)
            before.flush()
            after.flush()
            options = icdiff.get_options()[0]
            options.no_headers = True
            icdiff.diff_files(options, before.name, after.name)
    print('')

print()
r = input('Write updated Eagle files? [Y/n] ')
if len(r) and r[0].lower() == 'n':
    sys.exit()

sch.write(sch_file)
brd.write(brd_file)


###############################################################################
## Try to reduce the Eagle file diff churn a little

# This is a bit obnoxious, but worth doing:
#
github jeffkaufman / icdiff / icdiff.py View on Github external
else:
            options.cols = 80

    headers = a, b
    if not options.print_headers:
        headers = None, None

    head = int(options.head)
    lines_a = open(a, "U").readlines()
    lines_b = open(b, "U").readlines()

    if head != 0:
        lines_a = lines_a[:head]
        lines_b = lines_b[:head]
        
    print ConsoleDiff(cols=int(options.cols),
                      show_all_spaces=options.show_all_spaces,
                      highlight=options.highlight,
                      line_numbers=options.line_numbers).make_table(
        lines_a, lines_b, headers[0], headers[1], context=options.context, numlines=int(options.numlines))
github cs50 / style50 / style50 / _api.py View on Github external
def split_diff(old, new):
        """
        Returns a generator yielding the side-by-side diff of `old` and `new`).
        """
        return map(lambda l: l.rstrip(),
                   icdiff.ConsoleDiff(cols=COLUMNS).make_table(old.splitlines(), new.splitlines()))
github Juniper / jsnapy / lib / jnpr / jsnapy / check.py View on Github external
def compare_diff(self, pre_snap_file, post_snap_file, check_from_sqlite):
        """
        This function is called when --diff is used
        """
        if check_from_sqlite:
            lines_a = pre_snap_file.splitlines(True)
            lines_b = post_snap_file.splitlines(True)
            headers = ("Snap_1", "Snap_2")
            options = get_options()[0]
            cd = ConsoleDiff(cols=int(options.cols),
                     show_all_spaces=options.show_all_spaces,
                     highlight=options.highlight,
                     no_bold=options.no_bold,
                     line_numbers=options.line_numbers,
                     tabsize=int(options.tabsize))
            for line in cd.make_table(
                    lines_a, lines_b, headers[0], headers[1],
                    context=(not options.whole_file),
                    numlines=int(options.unified)):
                codec_print(line, options)
                sys.stdout.flush()
        else:
            if os.path.isfile(pre_snap_file) and os.path.isfile(
                    post_snap_file):
                diff(pre_snap_file, post_snap_file)
            else:
github Juniper / jsnapy / lib / jnpr / jsnapy / check.py View on Github external
def compare_diff(self, pre_snap_file, post_snap_file, check_from_sqlite):
        """
        This function is called when --diff is used
        """
        if check_from_sqlite:
            lines_a = pre_snap_file.splitlines(True)
            lines_b = post_snap_file.splitlines(True)
            headers = ("Snap_1", "Snap_2")
            options = get_options()[0]
            cd = ConsoleDiff(cols=int(options.cols),
                     show_all_spaces=options.show_all_spaces,
                     highlight=options.highlight,
                     no_bold=options.no_bold,
                     line_numbers=options.line_numbers,
                     tabsize=int(options.tabsize))
            for line in cd.make_table(
                    lines_a, lines_b, headers[0], headers[1],
                    context=(not options.whole_file),
                    numlines=int(options.unified)):
                codec_print(line, options)
                sys.stdout.flush()
        else:
            if os.path.isfile(pre_snap_file) and os.path.isfile(
                    post_snap_file):
                diff(pre_snap_file, post_snap_file)
            else:
github Juniper / jsnapy / lib / jnpr / jsnapy / check.py View on Github external
def compare_diff(self, pre_snap_file, post_snap_file, check_from_sqlite):
        """
        This function is called when --diff is used
        """
        if check_from_sqlite:
            lines_a = pre_snap_file.splitlines(True)
            lines_b = post_snap_file.splitlines(True)
            headers = ("Snap_1", "Snap_2")
            options = get_options()[0]
            cd = ConsoleDiff(cols=int(options.cols),
                     show_all_spaces=options.show_all_spaces,
                     highlight=options.highlight,
                     no_bold=options.no_bold,
                     line_numbers=options.line_numbers,
                     tabsize=int(options.tabsize))
            for line in cd.make_table(
                    lines_a, lines_b, headers[0], headers[1],
                    context=(not options.whole_file),
                    numlines=int(options.unified)):
                codec_print(line, options)
                sys.stdout.flush()
        else:
            if os.path.isfile(pre_snap_file) and os.path.isfile(
                    post_snap_file):
                diff(pre_snap_file, post_snap_file)
github Juniper / jsnapy / lib / jnpr / jsnapy / check.py View on Github external
def compare_diff(self, pre_snap_file, post_snap_file, check_from_sqlite):
        """
        This function is called when --diff is used
        """
        if check_from_sqlite:
            lines_a = pre_snap_file.splitlines(True)
            lines_b = post_snap_file.splitlines(True)
            headers = ("Snap_1", "Snap_2")
            options = get_options()[0]
            cd = ConsoleDiff(cols=int(options.cols),
                     show_all_spaces=options.show_all_spaces,
                     highlight=options.highlight,
                     no_bold=options.no_bold,
                     line_numbers=options.line_numbers,
                     tabsize=int(options.tabsize))
            for line in cd.make_table(
                    lines_a, lines_b, headers[0], headers[1],
                    context=(not options.whole_file),
                    numlines=int(options.unified)):
                codec_print(line, options)
                sys.stdout.flush()
        else:
            if os.path.isfile(pre_snap_file) and os.path.isfile(
                    post_snap_file):
                diff(pre_snap_file, post_snap_file)
github Juniper / jsnapy / lib / jnpr / jsnapy / check.py View on Github external
if check_from_sqlite:
            lines_a = pre_snap_file.splitlines(True)
            lines_b = post_snap_file.splitlines(True)
            headers = ("Snap_1", "Snap_2")
            options = get_options()[0]
            cd = ConsoleDiff(cols=int(options.cols),
                     show_all_spaces=options.show_all_spaces,
                     highlight=options.highlight,
                     no_bold=options.no_bold,
                     line_numbers=options.line_numbers,
                     tabsize=int(options.tabsize))
            for line in cd.make_table(
                    lines_a, lines_b, headers[0], headers[1],
                    context=(not options.whole_file),
                    numlines=int(options.unified)):
                codec_print(line, options)
                sys.stdout.flush()
        else:
            if os.path.isfile(pre_snap_file) and os.path.isfile(
                    post_snap_file):
                diff(pre_snap_file, post_snap_file)
            else:
                self.logger_check.info(
                    colorama.Fore.RED +
                    "ERROR!!! Files are not present in given path", extra=self.log_detail)
github Juniper / jsnapy / lib / jnpr / jsnapy / check.py View on Github external
if check_from_sqlite:
            lines_a = pre_snap_file.splitlines(True)
            lines_b = post_snap_file.splitlines(True)
            headers = ("Snap_1", "Snap_2")
            options = get_options()[0]
            cd = ConsoleDiff(cols=int(options.cols),
                     show_all_spaces=options.show_all_spaces,
                     highlight=options.highlight,
                     no_bold=options.no_bold,
                     line_numbers=options.line_numbers,
                     tabsize=int(options.tabsize))
            for line in cd.make_table(
                    lines_a, lines_b, headers[0], headers[1],
                    context=(not options.whole_file),
                    numlines=int(options.unified)):
                codec_print(line, options)
                sys.stdout.flush()
        else:
            if os.path.isfile(pre_snap_file) and os.path.isfile(
                    post_snap_file):
                diff(pre_snap_file, post_snap_file)
            else:
                self.logger_check.info(
                    colorama.Fore.RED +
                    "ERROR!!! Files are not present in given path", extra=self.log_detail)

icdiff

improved colored diff

Python-2.0
Latest version published 1 year ago

Package Health Score

66 / 100
Full package analysis

Similar packages