Skip to main content

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.

Release files for macresources 1.2

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

Source distribution (sdist)

Source distribution for macresources 1.2
File Size Uploaded
macresources-1.2.tar.gz 23.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for macresources 1.2
File Interpreter ABI Platform
macresources-1.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 57.5 kB

Release files / macresources-1.2.tar.gz

Download URL macresources-1.2.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f5a1465e02b11e6bc2cb9f2221e0cfac90d57d294b6baa73c28035b000c3dec4
BLAKE2b-256 checksum
How to use checksums
15b10a709220dca1038e7e5e6c86a22db3dc85f5708258eecd007668643d95a3
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / macresources-1.2-py2.py3-none-any.whl

Download URL macresources-1.2-py2.py3-none-any.whl
Size 33.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
6aac6ee6c8170ad0d7e2b3ee810b97eede3bd6ff421097dfb59fc7b88c53f9fb
BLAKE2b-256 checksum
How to use checksums
e492a056fa4f262f57d43f48b43c3cdb8eedd4c51e6e1046abbe481c3df5dd46
Upload date
Uploaded using Trusted Publishing?
What is 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
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