473,323 Members | 1,560 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Generating side-by-side differences in HTML

The difflib.py module and the diff.py tools script in Python 2.4 alpha
3 now support generating side by side (with intra line differences) in
HTML format. I have found this useful for performing build release
comparisons (I use a script to generate a main page showing all the
files that were changed in a build with hyperlinks to side by side
differences for each of those files). I also find it useful for
generating HTML test reports to show differences between actual and
expected log files. In addition I use it for supplementing Doxygen
generated HTML with side by side differences of files that were
changed.

Example usages:

<DOS_CMD_LINE>
c:/python2x/Tools/Scripts/diff.py -m file1.txt file2.txt > some.html
</DOS_CMD_LINE>

<SOME_PYTHON_SCRIPT>
import difflib
file1 = 'file1.txt'
file2 = 'file2.txt'
lines1 = open(file1).readlines()
lines2 = open(file2).readlines()
differ = difflib.HtmlDiff(tabsize=4,wrapcolumn=80)
html = differ.make_file(lines1,lines2,file1,file2,context =True,numlines=10)
f = open('some.html','w')
f.write(html)
f.close()
</SOME_PYTHON_SCRIPT>

'tabsize' defaults to 8
'wrapcolumn' defaults to None (no line wrapping)
'context' defaults to False (shows full file vs. just showing diffs +
context)
'numlines' defaults to 5

You can try out the code either by installing Python 2.4 alpha 3 or
you can obtain the patched files (and example output) from:
https://sourceforge.net/tracker/?fun...&group_id=5470

Enjoy,
Dan Gass
Jul 18 '05 #1
0 1880

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

Similar topics

6
by: paul | last post by:
Hi, I'd like to generate PDF files from my Php website. I've found PDFLib to make it... but i'd like to have your views. It is the best I can find ? Are there any other PDF generating lib ?...
3
by: skn | last post by:
Hello., Does the python compiler provide an option to generate a .pyo(optimized byte code file) from a .py (source file)? For generating .pyc I know that I only have to pass the source file...
3
by: Steve Dussinger | last post by:
Hi All: I am attempting to use an XSL stylesheet to take data from an existing DOM document, and place it into a different existing DOM document. The problem I'm having is that I get the...
7
by: eric.gagnon | last post by:
In a program randomly generating 10 000 000 alphanumeric codes of 16 characters in length (Ex.: "ZAZAZAZAZAZAZ156"), what would be an efficient way to ensure that I do not generate duplicates? ...
10
by: Al Christoph | last post by:
Please forgive me if this is the wrong place to post this. The last place I posted got me a fairly rude response. I guess vb.db people just don't want to think about XML as database. At any rate,...
6
by: Poul Møller Hansen | last post by:
I have made a stored procedure, containing this part for generating a unique reference number. SET i = 0; REPEAT SET i = i + 1; SELECT RAND() INTO reference FROM SYSIBM.SYSDUMMY1; SET...
3
by: Raed Sawalha | last post by:
Hello when I serialize an object an error generated using this function public string SerializeObject(object oClassObject,System.Type oClassType) { XmlSerializer oSerializer = new...
1
by: Nathan Sokalski | last post by:
Visual Studio 2005 recently stopped generating the *.designer.vb files for my *.aspx and *.ascx files. I am using Service Pack 1, and do not believe I did anything differently than normal prior to...
0
by: Aswanth | last post by:
I'm Generating Reports in SSRS-2005.. Previously I got the Data from One Database & Generated Reports.. Now I used to get the Data from Two Different Databases(ie Database-1 & Database-2) & to...
0
by: Aswanth | last post by:
I'm Working with Asp.Net with C#.. & I'm Generating Reports in SSRS-2005.. Till Now I'm Generating Reports in SSRS-2005 with Stored Procedure.. in Which I'm Generating Reports for One...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.