Skip to main content

oaknut-dfs

PyPI version CI Python versions License: MIT

A Python library for reading, writing, and creating Acorn DFS floppy disc images, as used by the BBC Micro.

With oaknut-dfs you can open DFS floppy images (SSD/DSD) to browse the catalogue, read and write files, inspect metadata, and create new formatted discs — all from Python, with a pathlib-inspired API.

Looking for ADFS? The hierarchical Advanced Disc Filing System lives in the sibling oaknut-adfs package (from oaknut.adfs import ADFS). DFS and ADFS are independent filing systems and independent packages. For a unified command-line tool across DFS, ADFS, AFS, ROMFS and ZIP, see oaknut-disc.

Part of the oaknut monorepo.

Supported formats

  • Acorn DFS — 40-track and 80-track, single-sided (SSD) and double-sided (DSD)
  • Watford DFS — extended catalogue supporting up to 62 files
  • DSD interleaving — both interleaved and sequential double-sided layouts

Acorn load/exec addresses, the lock bit, and the BBC Micro character set (the acorn text codec, £, ¦) are handled through the shared oaknut-file metadata layer.

Installation

uv add oaknut-dfs      # or: pip install oaknut-dfs

oaknut-dfs is a standard Python package installable with any package manager; the examples use uv.

Usage

Opening and reading files

The disc format is auto-detected from the file extension and size; pass a format explicitly only to override detection.

from oaknut.dfs import DFS

with DFS.from_file("Zalaga.ssd") as dfs:
    print(dfs.title)

    # Navigate with a pathlib-inspired API.
    for entry in dfs.root / "$":
        s = entry.stat()
        print(f"{entry.name:10s}  {s.length:6d}  load={s.load_address:08X}")

    # Read file data.
    data = (dfs.root / "$" / "ZALAGA").read_bytes()
    print(len(data), "bytes")

Output:

ZALAG-L
ZALAGA?      11557  load=00003000
ZALAGA        2816  load=000023EE
ZALAG-L       3328  load=00001900
!BOOT           48  load=00000000
2816 bytes

Creating a new disc

from oaknut.dfs import ACORN_DFS_80T_SINGLE_SIDED, DFS

with DFS.create_file("demo.ssd", ACORN_DFS_80T_SINGLE_SIDED, title="DEMO") as dfs:
    (dfs.root / "$.HELLO").write_bytes(b"Hello, World!", load_address=0x1900)
    (dfs.root / "$.README").write_bytes(b"oaknut-dfs demo disc")

with DFS.from_file("demo.ssd") as dfs:
    print(dfs.title, [str(f.path) for f in dfs.files])

Output:

DEMO ['$.README', '$.HELLO']

Double-sided discs (DSD)

A DSD image holds two independent sides, each with its own catalogue — mirroring the BBC Micro, where the sides were accessed as separate drives (*DRIVE 0 and *DRIVE 2). Select a side with the side= argument.

from oaknut.dfs import DFS

with DFS.from_file("game.dsd") as side0:
    print(side0.title)

with DFS.from_file("game.dsd", side=1) as side2:
    print(side2.title)

Output:

SIDE0
SIDE1

Walking the disc

DFS directories ($, A–Z) appear as children of a virtual root:

from oaknut.dfs import DFS

with DFS.from_file("disc.ssd") as dfs:
    for dirpath, dirnames, filenames in dfs.root.walk():
        for name in filenames:
            print(dirpath / name)

Output:

$.LOCKED
$.BINARY
$.ABCDEFG
$.X
$.MULTI
$.TEXT
B.FILE2
B.FILE1
A.DATA3
A.DATA2
A.DATA1

Development

The package is developed in the oaknut workspace. From the repository root:

uv sync                                 # install all workspace members editable
uv run pytest packages/oaknut-dfs/tests # this package's tests
uv run ruff check                       # lint

Architecture

A layered design, dependencies flowing strictly downward (every module imports only from the layer below):

DFS (dfs.py)                       user-facing DFS / DFSPath / DFSStat
  ↓
CataloguedSurface (catalogued_surface.py)
  ↓
Catalogue ABC (catalogue.py)   ←   AcornDFSCatalogue / WatfordDFSCatalogue
  ↓
Surface / SectorsView          (from oaknut-discimage)
  • dfs.py — user-facing DFS, DFSPath, DFSStat; methods mirror the DFS star commands (load, save, delete, rename, lock, …).
  • catalogue.py — the catalogue ABC (Catalogue, FileEntry, DiscInfo): 31-file cap, single-character directories, 7-char names.
  • acorn_dfs_catalogue.py / watford_dfs_catalogue.py — the Acorn (sectors 0–1, 31 files) and Watford (sectors 0–3, 62 files) catalogues.
  • catalogued_surface.py — pairs a Surface with a Catalogue.
  • formats.py — DFS and Watford disc-format constants.

Sector-level access (Surface, SectorsView, UnifiedDisc) lives in oaknut-discimage; metadata and the acorn codec in oaknut-file; BBC BASIC (de)tokenisation (for DFSPath.read_basic / write_basic) in oaknut-basic.

References

License

MIT — see LICENSE.

Metadata

Release files for oaknut-dfs 13.5.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 oaknut-dfs 13.5.0
File Size Uploaded Provenance Actions
oaknut_dfs-13.5.0.tar.gz 116.4 kB Without provenance Details for oaknut_dfs-13.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for oaknut-dfs 13.5.0
File Interpreter ABI Platform Actions
oaknut_dfs-13.5.0-py3-none-any.whl Python 3 none any Details for oaknut_dfs-13.5.0-py3-none-any.whl

Total release size: 175.5 kB

Release files / oaknut_dfs-13.5.0.tar.gz

Download URL oaknut_dfs-13.5.0.tar.gz
Size 116.4 kB
Tags Source
SHA-256 checksum
How to use checksums
80f22af35f6b0e8943fd96e3e13148252bd666b4ba34f54ac3ceb857c30b8765
BLAKE2b-256 checksum
How to use checksums
5c966ec1f5267d616f0e410ec58294ff1db786db5b5809741a494e398203c80e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / oaknut_dfs-13.5.0-py3-none-any.whl

Download URL oaknut_dfs-13.5.0-py3-none-any.whl
Size 59.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab86f18283dff2d08355f492377bd43fc34989c34d145ac7cffe3c7b38b0b83e
BLAKE2b-256 checksum
How to use checksums
18856d7f5461cfd618155848bb26d79c23ba88f14621f151fbd7818b5f7cda7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for oaknut-dfs 13.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

13.5.0 This release

2 release files No provenance

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