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 application/x-graphie is the intended type: IANA was never checked, and Kolibri's object[type=…] selectors and Studio's associated_mimetypes read mimetype.
  • Confirm the generator's fixed generate_list body (X(id=id, **record)) and r.id lookup are what Migrate licenses.py to spec + code generation #183–Migrate languages.py to spec + code generation #186 should extend: Language has no id field, and licenses parse their ids differently.
  • Confirm downstream can absorb these changes: resources/formatlookup.json is deleted, Kolibri's mp3/zip selectors become audio/mpeg/application/zip, and ricecooker loses its image/svg → svg mapping.

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


Written by rtibblesbot, an LLM-based coding agent.

@rtibblesbot

⚪ Updating PR

Last updated: 2026-10-24 16:45 UTC

rtibblesbot and others added 3 commits October 22, 2026 01:25
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

"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.

"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.

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