Skip to main content

A universal "diff" patch parsing library.

Project description

The parsedifflib package parses any style of diff patch into an event stream of patch instructions. These instructions can then be applied, colorized, reformatted, dissected, analyzed, etc.


2013/12/09: currently only the svnlook format and stream-oriented event output is supported. Eventually, all the formats supported by colordiff are intended to be supported as well as structured output.


import parsedifflib, subprocess

data = subprocess.check_output('svnlook diff /path/to/repos', shell=True)

for event, target in parsedifflib.parse_svnlook(data, {'lineNumbers': True}):

  if event in ( parsedifflib.Event.PATCH_START,

  elif event == parsedifflib.Event.ENTRY_START:
    print target.comment

  elif event == parsedifflib.Event.LINE_DELETE:
    print '  - deleted line %d: %s' % (target.oldnum, target.line)

  elif event == parsedifflib.Event.LINE_DELETE:
    print '  + added line %d: %s' % (target.newnum, target.line)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for parsedifflib, version 0.2.0
Filename, size & hash File type Python version Upload date
parsedifflib-0.2.0.tar.gz (23.6 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page