On Thursday, June 15, 2017 at 8:33:12 AM UTC-5, Terry Brown wrote: You're aware of > > https://docs.python.org/2/library/difflib.html >
The question is how to get the "raw material" for difflib. I have just answered my second stack overflow <https://stackoverflow.com/questions/44568306/gitpython-how-to-show-diffs-between-blobs-in-a-human-readable-format-as-in-git> question. My answer shows just how unimpressed I am with the gitpython docs, which do more harm than good. Anyway, after getting a blob from gitpython, g.toUnicode(blob.data_stream.read()) gets the contents of the blob. Here is my present test script: import git repo = git.Repo(r'C:/leo.repo/leo-editor') diff_index = repo.head.commit.diff('HEAD~1') # A DiffIndex object, not a plain list. for d in diff_index: s1 = g.toUnicode(d.a_blob.data_stream.read()) s2 = g.toUnicode(d.b_blob.data_stream.read()) print('%s %6s %6s %s' % ( d.change_type, id(d.a_blob), id(d.b_blob), d.a_path)) print(s1) print(s2) break # Just show commit_timestamp.json And here is the output: M 150586976 150587168 leo/core/commit_timestamp.json { "asctime": "Wed Jun 14 06:21:17 CDT 2017", "timestamp": "20170614062117" } { "asctime": "Wed Jun 14 06:14:24 CDT 2017", "timestamp": "20170614061424" } So now I can pass s1 and s2 to difflib. Mission accomplished. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
