Skip to main content

VCS fastimport/fastexport parser

Project description

python-fastimport

This package provides a parser for and generator of the Git fastimport format. (https://www.kernel.org/pub/software/scm/git/docs/git-fast-import.html)

Installation

pip install fastimport

Example

Here's a simple example of how to parse a fastimport stream:

from fastimport import parser

# Parse a fastimport stream from a file
with open('export.dat', 'rb') as f:
    p = parser.ImportParser(f)
    for cmd in p.iter_commands():
        if cmd.name == b'commit':
            print(f"Commit to branch: {cmd.ref}")
            print(f"Author: {cmd.author}")
            print(f"Message: {cmd.message}")
        elif cmd.name == b'blob':
            print(f"Blob mark: {cmd.mark}, size: {len(cmd.data)}")

And here's how to generate a fastimport stream:

from fastimport import commands

# Create a new blob
blob = commands.BlobCommand(
    mark=b'1',
    original_oid=None,
    data=b'Hello, World!\n',
    lineno=0
)

# Create a commit
commit = commands.CommitCommand(
    ref=b'refs/heads/main',
    mark=b'2',
    original_oid=None,
    author=(b'John Doe', b'john@example.com', 1234567890, 0),
    committer=(b'John Doe', b'john@example.com', 1234567890, 0),
    message=b'Initial commit\n',
    from_=None,
    merges=None,
    file_iter=[
        commands.FileModifyCommand(
            path=b'hello.txt',
            mode=0o100644,
            dataref=b':1',
            data=None
        )
    ]
)

# Write to a fastimport stream
with open('import.dat', 'wb') as f:
    f.write(bytes(blob))
    f.write(b'\n')
    f.write(bytes(commit))

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

fastimport-0.9.15.tar.gz (50.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastimport-0.9.15-py2.py3-none-any.whl (46.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file fastimport-0.9.15.tar.gz.

File metadata

  • Download URL: fastimport-0.9.15.tar.gz
  • Upload date:
  • Size: 50.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fastimport-0.9.15.tar.gz
Algorithm Hash digest
SHA256 5f5502afbc36f5935eef30ebd052ebbdfdb97d6004b8121ebcf4450da8520b5f
MD5 948f283ff07f60a1341b8aa62d769d6c
BLAKE2b-256 62615f169e842694b480127b3a1ca0959cc69d7a9925e51e4534c02b89a17d91

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastimport-0.9.15.tar.gz:

Publisher: wheels.yaml on jelmer/python-fastimport

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastimport-0.9.15-py2.py3-none-any.whl.

File metadata

  • Download URL: fastimport-0.9.15-py2.py3-none-any.whl
  • Upload date:
  • Size: 46.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fastimport-0.9.15-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e527b02e03d5be62fe4451764b510c84f5d6884e566db86443e8e27ee7311a48
MD5 8e8e683b8d5a6ccf283c1c11afa8dbed
BLAKE2b-256 e594762067d08ba77148dfcc4d06826eb49195509bc5c0831f69cf4ef501ea94

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastimport-0.9.15-py2.py3-none-any.whl:

Publisher: wheels.yaml on jelmer/python-fastimport

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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