LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Patching Python files (https://www.linuxquestions.org/questions/linux-software-2/patching-python-files-488720/)

Dee-ehn 10-02-2006 09:23 AM

Patching Python files
 
Hi all,

I modified some existing Python files. Now I like to write some patching script which patches identical files with my modifications. I could of course pull a dirty trick by overwriting the originals by the new files, but I'd prefer to use a pretty patching technique. I think the linux "patch" tool can help me here, but I realy can't figure out how to do this in a good way.

Can anybody give me a good tip or perhaps some tutorial how to make good patches? Of course, information on other techniques is interesting too.

Thanks in advance, Robin

unSpawn 10-02-2006 04:57 PM

(Note diff does line by line comparisons, so will only work with text, not binary.)
Have (a copy of) the original and the modified file in the same directory.
Do "diff -Naur original_file modified_file > modification.diff" to get the changes between them in a file.
Now if you want to modify the original you would "patch original_file < modification.diff".
Done.

Dee-ehn 10-03-2006 02:02 AM

Quote:

Originally Posted by unSpawn
(Note diff does line by line comparisons, so will only work with text, not binary.)
Have (a copy of) the original and the modified file in the same directory.
Do "diff -Naur original_file modified_file > modification.diff" to get the changes between them in a file.
Now if you want to modify the original you would "patch original_file < modification.diff".
Done.

Thanks, that's really easy. It's indeed only text (.py) I need to patch. Muchos thankos.


All times are GMT -5. The time now is 02:33 PM.