-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
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
APIs? #131
Comments
Sorry, haven't noticed this: #105 |
I reopen this because I found the APIs are not so convenient to be integrated. For example, if I want to compare two files in my program, I have to modify the def _getIcOptions():
origargv = [arg for arg in sys.argv]
options = icdiff.get_options()[0]
sys.argv = origargv
return options
def ndiff(a, b, linejunk=None, charjunk=difflib.IS_CHARACTER_JUNK):
options = _getIcOptions()
cd = icdiff.ConsoleDiff(
cols = int(options.cols),
show_all_spaces = options.show_all_spaces,
highlight = options.highlight,
line_numbers = options.line_numbers,
tabsize = int(options.tabsize)
)
with warnings.catch_warnings():
warnings.simplefilter('ignore')
for line in cd.make_table(
a, b, 'First', 'Second',
context=(not options.whole_file),
numlines=int(options.unified)):
line = "%s\n" % line
yield line.encode(options.output_encoding) |
Can you just use the difflib api? What sort of program do you have that you want to invoke icdiff via api? (In general, icdiff is trying to be a tool for users to invoke directly) |
@jeffkaufman I understand. But the reason (the beauty of line-by-line comparison and colorized output) why I replaced |
Thinking about this, it's fine with me if someone wants to make a PR to add API support. |
icdiff
is great!But do we have any plans to expose the APIs like
difflib
?The text was updated successfully, but these errors were encountered: