LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-02-2006, 09:23 AM   #1
Dee-ehn
Member
 
Registered: Apr 2004
Distribution: Suse 9 pro
Posts: 52

Rep: Reputation: 15
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
 
Old 10-02-2006, 04:57 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
(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.
 
Old 10-03-2006, 02:02 AM   #3
Dee-ehn
Member
 
Registered: Apr 2004
Distribution: Suse 9 pro
Posts: 52

Original Poster
Rep: Reputation: 15
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Python doesn't make pyc files GiantBucket Programming 2 03-13-2006 05:04 AM
coping neccesary python files to chroot area dominant Linux - Security 6 12-17-2004 03:30 AM
Python and binary files The_Nerd Programming 2 08-27-2004 02:48 PM
reading fields from files in python without \t \n dumpthecore Programming 1 12-11-2003 04:57 AM
Regex search in files with python smokybobo Programming 0 11-08-2003 06:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration