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.

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)

Credits

Much inspiration came from:

Project details


Download files

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

Source Distribution

parsedifflib-0.2.0.tar.gz (23.6 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page