skip to navigation
skip to content

Not Logged In

parsedifflib 0.1.0

A universal "diff" patch parsing library.

Latest Version: 0.2.0

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.

Warning

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.

Usage

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,
                parsedifflib.Event.PATCH_END,
                parsedifflib.Event.ENTRY_END,
                parsedifflib.Event.LINE_LOC,
                parsedifflib.Event.LINE_SAME,
                parsedifflib.Event.LINE_NOTE,
                parsedifflib.Event.PROPENTRY,
              ):
    continue

  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)
 
File Type Py Version Uploaded on Size
parsedifflib-0.1.0.tar.gz (md5) Source 2013-12-12 21KB
  • Downloads (All Versions):
  • 5 downloads in the last day
  • 34 downloads in the last week
  • 226 downloads in the last month