Skip to main content

Python bindings to the chdimage part of https://github.com/Manorhos/imageparse

Project description

This small project is a binding to the chd part of the rust project imageparse done for its capability to access chd files decompressed bytes, even those with parents, recognize the track boundaries, and calculate their sha1 checksums.

Upstream has some limitations still:

  1. Will not load hard drive chds, since it’s out of scope of the project.

  2. Will not yet read gdi chds, although that’s possible in the future.

  3. Like the upstream it depends on, chd-rs it can’t write a new chd.

  4. It is not actually a filesystem mounter, it only accesses the raw decompressed bytes and recognizes track boundaries.

You can access the chd track sha1 checksums of b.chd with parent a.chd like this:

import chdimage
chd = chdimage.open_with_parent('b.chd', ['a.chd'])
sha1sums = [ bytes(x).hex() for x in chd.track_sha1s() ]

Chd files that aren’t parents are ignored, so you can choose your own strategy to find parents:

chd = chdimage.open_with_parent('b.chd', ['not_b_parent.chd', 'a.chd'])

You can iterate over the track bytes like this:

for x in range(0,chd.num_tracks()):
  event = None
  #tracks go from 1 to num_tracks(), 0 does not count
  print(f'track {x+1}')
  while event != Event.TRACKCHANGE and event != Event.ENDOFDISC:
    sector = chd.copy_current_sector()
    event = chd.advance_position()
    #printing bytes is useless and lossy, do something else
    print(bytes(sector).decode(errors='replace'))

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

chdimage-0.2.1-cp38-abi3-win_amd64.whl (270.3 kB view hashes)

Uploaded CPython 3.8+ Windows x86-64

chdimage-0.2.1-cp38-abi3-win32.whl (254.7 kB view hashes)

Uploaded CPython 3.8+ Windows x86

chdimage-0.2.1-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.4 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ s390x

chdimage-0.2.1-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.3 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ppc64le

chdimage-0.2.1-cp38-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl (1.3 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ppc64

chdimage-0.2.1-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.2 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARMv7l

chdimage-0.2.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARM64

chdimage-0.2.1-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.5+ x86-64

chdimage-0.2.1-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.5+ i686

chdimage-0.2.1-cp38-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (769.3 kB view hashes)

Uploaded CPython 3.8+ macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

chdimage-0.2.1-cp38-abi3-macosx_10_7_x86_64.whl (394.4 kB view hashes)

Uploaded CPython 3.8+ macOS 10.7+ x86-64

Supported by

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