Skip to content

Generate file_formats from a namedtuple spec and correct seven mimetypes - #250

Open
rtibblesbot wants to merge 3 commits into
learningequality:mainfrom
rtibblesbot:issue-182-3e81b3
Open

rtibblesbot wants to merge 3 commits into
learningequality:mainfrom
rtibblesbot:issue-182-3e81b3

Conversation

@rtibblesbot

@rtibblesbot rtibblesbot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • file_formats and js/FileFormats.js are generated from one spec, replacing the hand-maintained module and partial JSON lookup.
  • Snapshot test pins the public API of the five legacy constants modules.
  • Seven mimetypes that were extensions or non-standard types are corrected.
  • getformat honours its default.
  • Kolibri, Studio and ricecooker checked against the corrected mimetypes: none needs a change, so no follow-up issues.

References

Closes #182. Part of #181.

Reviewer guidance

Suggested review: Full code review, then manual QA once the reviewer sets Needs QA.

  • User-visible files changed: js/FileFormats.js.
  • Confirm downstream can take the mimetype changes: Studio's loadconstants writes them into stored FileFormat.mimetype rows, Kolibri's mp3/zip object[type=…] selectors become audio/mpeg/application/zip, and ricecooker loses its image/svg → svg mapping.
  • Confirm Migrate licenses.py to spec + code generation #183–Migrate languages.py to spec + code generation #186 should copy this generator shape: it hard-codes an id field (record["id"], r.id) and one generate_list body (X(id=id, **record)), but Language has no id field and License is built differently.
  • Confirm application/x-graphie should stand: no registry entry or Kolibri mapping backs it.

Commits run pin → migrate (snapshot unchanged) → correct (snapshot diff is only the seven mimetypes).

AI usage

Used Claude Code to write the generator, spec, snapshot test and corrections, and to trace the Kolibri, Studio and ricecooker consumers. Verified with the full test suite, make build idempotence, and prek.

🤖 Generated with Claude Code

Deviations from the issue spec

Criterion Why not
h5p gets an IANA, x- or vendor type Review asked for application/h5p+zip, matching the other +zip formats and Kolibri's mimetypes.js

Written by rtibblesbot, an LLM-based coding agent.

@rtibblesbot

🟡 Waiting for feedback

Last updated: 2026-10-25 17:58 UTC

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rtibblesbot
rtibblesbot marked this pull request as ready for review October 22, 2026 01:51
@rtibblesbot
rtibblesbot requested review from a team and leq-bot October 22, 2026 01:51

@rtibbles rtibbles left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two mimetype changes needed. Neither type is IANA-registered, so pick values that match existing conventions:

  • h5p → application/h5p+zip. This matches how we handle other zip files with custom extensions (perseus+zip, bloompub+zip, kpub+zip), and Kolibri's packages/kolibri/utils/mimetypes.js already maps it to h5p.
  • zim → application/x-openzim. That's the type freedesktop shared-mime-info registers for *.zim.

Update the spec, regenerated files, tests/pinned_api.json, the CHANGELOG and the PR description to match.

Comment thread spec/constants-file_formats.json Outdated
"label": "H5P",
"field_constants": ["mimetype"],
"id": "h5p",
"mimetype": "application/x-h5p"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use application/h5p+zip here, to match the other zip-based formats with custom extensions and Kolibri's existing mimetypes.js mapping.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to application/h5p+zip in 01ff28e: spec, generated Python/JS, tests/pinned_api.json, CHANGELOG, PR description. Searched for other invented x- types: only graphie (application/x-graphie) remains, left as-is since it is not a zip with a custom extension.

Comment thread spec/constants-file_formats.json Outdated
"label": "ZIM",
"field_constants": ["mimetype"],
"id": "zim",
"mimetype": "application/x-zim"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use application/x-openzim here. It's the freedesktop shared-mime-info type for *.zim.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to application/x-openzim in 01ff28e, with the same files updated.

rtibblesbot and others added 2 commits October 25, 2026 17:45
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add namedtuple spec support and migrate file_formats.py

2 participants