We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
Apologies if this was asked already.. couldn't find the answer.
Is it possible to use cdiff programmatically from the Python script?
cdiff
Something like this:
import cdiff diff_string = get_diff_somehow() cdiff.print_colorized(diff_string)
This would be super useful for the utility we are writing.
Thanks!
The text was updated successfully, but these errors were encountered:
DiffParser and DiffMarker might be what you want, I imagine you will have the same logic as [1], sorry I don't have enough docstring in the file.
DiffParser
DiffMarker
[1] https://github.com/ymattw/cdiff/blob/a1a33a52/cdiff.py#L642-L647
Sorry, something went wrong.
It works well, thanks @ymattw!
Here is the basic usage if anyone's interested:
import sys from io import StringIO from cdiff import ( PatchStream, DiffParser, DiffMarker, ) diff_str = """\ diff --git a/file.txt b/file.txt index ada066f..a252b8c 100644 --- a/file.txt +++ b/file.txt @@ -1,4 +1,4 @@ line 1 -line 2 -line 3 +this is a new line +line change 3 """ raw_stream = StringIO(diff_str) # open('file.diff', 'r') stream = PatchStream(raw_stream) diffs = DiffParser(stream).get_diff_generator() marker = DiffMarker() color_diff = marker.markup(diffs) for line in color_diff: sys.stdout.write(line)
No branches or pull requests
Hi,
Apologies if this was asked already.. couldn't find the answer.
Is it possible to use
cdiff
programmatically from the Python script?Something like this:
This would be super useful for the utility we are writing.
Thanks!
The text was updated successfully, but these errors were encountered: