GNU patch と互換性のある python モジュール difflib でパッチを作成することはできますか? Unified_diff と context_diff を使用しようとし、lineterm を "\n" として指定しようとしましたが、まだこのエラーが発生します:
[intense@Singularity Desktop]$ patch diff.patch test.txt
patch unexpectedly ends in middle of line
patch: **** Only garbage was found in the patch input.
file.writelines(diff) を使用してパッチをファイルに書き込みました (コードhttp://pastebin.com/3HAWfwVf )
ファイル test.txt:
Hello, this is test
blah
ファイル test2.txt:
Hello, this is test
blah, dfsgjdfgj
lfkdjgkldfjgkldfjgkl
そして生成されたパッチ:
--- /home/intense/Desktop/test.txt
+++ /home/intense/Desktop/test2.txt
@@ -1,2 +1,7 @@
-Hello, this is test
-blah+Hello,+this+is+test+blah,+dfsgjdfgj+lfkdjgkldfjgkldfjgkl
助けてくれてありがとう。