473,772 Members | 3,786 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Has anybody used cx_bsdiff?

Hello,

I am trying to use cx_bsdiff
(http://starship.python.net/crew/atui...iff/index.html) to to
make a diff and patch some files. It appears that I can make the diff,
but when I apply the patch, the result is not the same.

As far as I understand the documentation, I am using this correctly.
Can anyone help me find what is wrong in the code below?

Thanks. Please reply to the list.

NR.

=============== =============== =============== ============

import bsdiff, bz2
import cPickle as pickle
from filecmp import dircmp
def diffdir(compara tor, basepath=''):
return [os.path.join(ba sepath, fname)
for fname in comparator.diff _files]
def descend(compara tor, basepath=''):
print 'Examining "%s"...' % basepath
yield diffdir(compara tor, basepath)
for subdir in comparator.subd irs:
subname = os.path.join(ba sepath, subdir)
subcmp = comparator.subd irs[subdir]
for subresult in descend(subcmp, subname):
yield subresult
def compare_all(ori g_dir, fix_dir):
patch = {}
comparator = dircmp(orig_dir , fix_dir, [])
for diff_list in descend(compara tor):
for diff_file in diff_list:
orig_fname = os.path.join(or ig_dir, diff_file)
fix_fname = os.path.join(fi x_dir, diff_file)
print 'Making diff of %s...' % diff_file
orig_data = open(orig_fname , 'rb').read()
fix_data = open(fix_fname, 'rb').read()
dl = len(fix_data)
ctrl, dblock, xblock = bsdiff.Diff(ori g_data, fix_data)
patch[diff_file] = (dl, ctrl, dblock, xblock)
print 'Done.'
return patch
def fix_all(tofix_d ir, patch):
for fname in patch:
orig_fname = os.path.join(to fix_dir, fname)
print 'Fixing %s...' % orig_fname
datafile = open(orig_fname , 'rb')
orig_data = datafile.read()
datafile.close( )
fix_data = bsdiff.Patch(or ig_data, *patch[fname])
datafile = open('%s-fixed' % orig_fname, 'wb')
datafile.write( fix_data)
datafile.close( )
os.remove(orig_ fname)
os.rename('%s-fixed' % orig_fname, orig_fname)
def save(object, filename, protocol=-1):
compressed = bz2.BZ2File(fil ename, 'wb')
compressed.writ e(pickle.dumps( object, protocol))
compressed.clos e()
def load(filename):
compressed = bz2.BZ2File(fil ename, 'rb')
object = pickle.loads(co mpressed.read() )
compressed.clos e()
return object
def make_patch():
orig_dir = raw_input('Orig inal Directory: ')
fix_dir = raw_input('Fixe d Directory: ')
savepatch = raw_input('Save result? (y/n): ')
if savepatch == 'y':
patchname = raw_input('Patc h file name: ')
else: savepatch = ''
patch = compare_all(ori g_dir, fix_dir)
if savepatch:
save(patch, patchname)

Oct 25 '05 #1
0 1482

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1533
by: Jim J | last post by:
I have been trying to find some kind of authentication method or script (PHP/perl/javascript or other) to achieve the following, with no luck. Say there are 100 files at a site. A person can choose which file to download from a list, and to do so has to enter a code or password. When a valid code or password is used they are redirected to a page with a direct link to download the file. Once that code or password has been used to...
0
1119
by: Christian Tismer | last post by:
Hi colleagues, this is my second attempt to get rid of the f_tstate field in frames. I need to find every user of this field. What am I talking about? Well, Python always has a thread state variable which is a unique handle to the current thread. This variable is accessed in many places, and there exists a fast macro to get at it.
0
1037
by: Christian Tismer | last post by:
Dear Python community, since I didn't get *any* reply to this request, either the request was bad or there is really nobody using f_tstate in a way that makes it urgent to keep. I will wait a few hours and then make the change to Stackless, and I'd like to propose to do the same to the Python core.
4
1606
by: siddurampure | last post by:
PLZ ANYBODY KNOWS WHY ICAP PROTOCOL IS USED?
1
1178
by: Craig G | last post by:
we are looking at the possibility of using Aspose.Word in our asp.net application to produce a simple doc, which will be a batch of standardised letters with different names addresses etc just wondering has anybody else used this? and what are your opinions on it? Cheers, Craig
2
1572
by: rocksoft | last post by:
Hi I am working in asp.net with C# web application, I have used visual studio 2003, i have used dropdownlist in my application to populate the data from mysql database, i have got problem while i selected the item from dropdownlist, its not selecting correct item i'm selecting from dropdownlist, i have 64 records in my table, but i tried to work with upto 15 records it will not giving problem, when the scroll will enable to dropdownlist...
1
2543
by: JSievers | last post by:
Hallo. A good friend of me develops web suites, for example his own at: www.augenpunkte.de. As you can see there my friend is blind and also he uses a Braille-line to develop these projects. For example his own suite at. But he has a big problem to find out the right colours for his pages and so he asked me for a big list with some colour schemes. A hex-colour-value for each part of a page (Text, Links e.g.) So I have had a look at some...
17
2310
by: raylopez99 | last post by:
What good is C# Reflection, other than to find out what types are in an assembly? And to dynamically invoke methods in an assembly (.dll or .exe)? Also, bonus question, can you use Reflection to build a compiler? One that will construct a user defined class "on the fly" (literally, the user defines a class, instantiates it, and runs it from the console mode, all the while prompted by the program)? I guess so, but my final question...
6
5684
by: raylopez99 | last post by:
Anybody use Strong Name Signing? I think this is used by default for Resource files, which is one reason perhaps I can't get my resource files to work (somehow the public key is messed up, perhaps since I've installed so many versions of Visual Studio) RL http://msdn.microsoft.com/en-us/library/h4fa028b.aspx Deployment in Visual Studio
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10104
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9912
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.