Skip to main content

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:

Metadata

Release files for parsedifflib 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for parsedifflib 0.2.0
File Size Uploaded
parsedifflib-0.2.0.tar.gz 23.6 kB Details

Release files / parsedifflib-0.2.0.tar.gz

Download URL parsedifflib-0.2.0.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
beea7cf12b04a5639cec0c2064bfdc9dded55c1711272b3a73a5cf11e55ff3c3
BLAKE2b-256 checksum
How to use checksums
f6495b7452ae3651af0f47061e14d2a0738397651c093219b00dd0970486a63a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.0

1 release file

0.0.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page