Skip to main content

Library for working with legacy Macintosh resource forks

Project description

macresources

A Python library and command line tools to work with Classic MacOS resource forks on a modern machine.

Data Format

First, macresources and its sister package machfs have a preferred representation for Macintosh files, where Macintosh-specific information is stored in separate text files.

  1. The data fork is stored inside a file with the original name. This must be present for the following two files to be recognised.

  2. The resource fork is stored in a 'Rez-style' textfile with .rdump appended to the original name. The format is slightly different from a vanilla 'DeRez' dump: non-ASCII characters are escaped, giving an ASCII-clean output:

     data '\0x96tbl' (0) {
         $"0000 0001 0000 0000 0000 0010 0669 4D61"            /* .............iMa */
         ...
     };
    
  3. The four-character type and creator codes are concatenated (like a PkgInfo file inside an app bundle) in a file with .idump appended to the original name. If the type is TEXT or ttro, then the data fork is converted to UTF-8 with Unix (LF) line endings.

Several other formats exist to store this Macintosh specific data in flat files, the best known being AppleSingle/AppleDouble, MacBinary and BinHex 4. The data format described here instead adapts text-friendly formats (Rez and PkgInfo). The result is especially useful for placing legacy Macintosh source code under modern version control.

The role of macresources is to produce and parse Rez-style .rdump files, and to produce and parse raw resource forks for machfs disk images.

Command Line Interface

rfx is a shell command wrapper for accessing resources inside a .rdump file. Command line arguments are passed through to the command, but resources specified as filename.rdump//type/id are converted to tempfiles before the command is run, and back to resources after the command returns. This approach even enables cp, mv and rm to work on individual resources.

rezhex and hexrez convert between BinHex (.hqx) format and macresources/macbinary format.

SimpleRez and SimpleDeRez are very simple reimplementations of the deprecated Rez and DeRez utilities. They convert between raw resource forks and Rez-style .rdump files. To access a raw resource fork under Mac OS X, you can append /..namedfork/rsrc to a filename.

Commands implementing Apple's undocumented resource compression scheme:

  • greggybits (in Python: from greggybits import pack, unpack)

All utilities have online help.

API

The Python API is pretty spartan. It exists mainly to support machfs and the command line interface.

from macresources import *

make_rez_code(from_iter, ascii_clean=False)     # Takes an iterator of Resource objects, returns Rez code
parse_rez_code(from_code)                       # Takes Rez code, returns an iterator of Resource objects
make_file(from_iter)                            # Takes an iterator of Resource objects, returns a raw resource fork
parse_file(from_file)                           # Takes a raw resource fork, returns an iterator of Resource objects

The Resource class inherits from bytearray.

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

macresources-1.2.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

macresources-1.2-py2.py3-none-any.whl (33.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file macresources-1.2.tar.gz.

File metadata

  • Download URL: macresources-1.2.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.6

File hashes

Hashes for macresources-1.2.tar.gz
Algorithm Hash digest
SHA256 f5a1465e02b11e6bc2cb9f2221e0cfac90d57d294b6baa73c28035b000c3dec4
MD5 94b139f9194eafc103e450ce8db3ece5
BLAKE2b-256 15b10a709220dca1038e7e5e6c86a22db3dc85f5708258eecd007668643d95a3

See more details on using hashes here.

File details

Details for the file macresources-1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: macresources-1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 33.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.6

File hashes

Hashes for macresources-1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6aac6ee6c8170ad0d7e2b3ee810b97eede3bd6ff421097dfb59fc7b88c53f9fb
MD5 13ba2835f83f3c3f773cddb721d7d95d
BLAKE2b-256 e492a056fa4f262f57d43f48b43c3cdb8eedd4c51e6e1046abbe481c3df5dd46

See more details on using hashes here.

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