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 details)

Uploaded Source

File details

Details for the file parsedifflib-0.2.0.tar.gz.

File metadata

  • Download URL: parsedifflib-0.2.0.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for parsedifflib-0.2.0.tar.gz
Algorithm Hash digest
SHA256 beea7cf12b04a5639cec0c2064bfdc9dded55c1711272b3a73a5cf11e55ff3c3
MD5 c1bab3b45c37ab972941bd6cfac84837
BLAKE2b-256 f6495b7452ae3651af0f47061e14d2a0738397651c093219b00dd0970486a63a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page