bigyo package

Subpackages

Module contents

bigyo

Bigyo (비교(KR): comparison) is Python library for side-by-side diff in terminal.

use difflib as its engine.

Supports beautiful output with multi-width or zero-width character.

date:

2023-01-10

Author:

LegenDUST

Version:

1.0.0

class bigyo.Bigyo(renderer=None)

Bases: object

Bigyo (ko: 비교, comparison) is class for side-by-side comparison, using difflib as its engine.

Simply replace:

difflib.Differ().compare(a, b)

to:

Bigyo().compare()

and you’ll get nice side-by-side comparison.

Parameters:

bigyo_renderer – Bigyo rendering strategy, which decides way to render comparison. It can be BigyoRenderer object, or None (which uses SimpleBigyoRenderer), defaults to None

compare(left, right)

Generator for generating side-by-side comparison.

Parameters:
  • left (Sequence[str]) – Left sequence to compare

  • right (Sequence[str]) – Right sequence to compare

Return type:

Iterator[str]

Returns:

Iterator, where next() call returns line with its difference.

comparison_string(left, right)

Return full compared string at once.

Is just return ''.join(self.compare(left, right)). Guess it will quite comes in handy.

Parameters:
  • left (Sequence[str]) – Left sequence to compare

  • right (Sequence[str]) – Right sequence to compare

Return type:

str