feat(sdk): addon asset path resolution — addon_resource() (#389) #401

Merged
forbes merged 1 commits from feat/sdk-addon-resource into main 2026-03-04 19:47:50 +00:00
Owner

Summary

Standard way for addons to locate their bundled assets (icons, translations, data files) without hardcoding paths.

Changes

  • registry.py — New addon_resource(name, relative_path) function that:
    • Looks up the addon's AddonManifest from FreeCAD.KindredAddons
    • Joins manifest.addon_root with the relative path
    • Validates the resolved path exists on disk
    • Raises LookupError if addon not registered, FileNotFoundError if path missing
  • init.py — Exports addon_resource

Usage

import kindred_sdk as sdk

icon = sdk.addon_resource("silo", "icons/silo_commit.svg")
# -> "/path/to/mods/silo/freecad/icons/silo_commit.svg"

# Works for any registered addon
template = sdk.addon_resource("gears", "data/defaults.json")

Replaces fragile os.path.dirname(__file__) patterns scattered across addons.

Closes #389

## Summary Standard way for addons to locate their bundled assets (icons, translations, data files) without hardcoding paths. ## Changes - **registry.py** — New `addon_resource(name, relative_path)` function that: - Looks up the addon's `AddonManifest` from `FreeCAD.KindredAddons` - Joins `manifest.addon_root` with the relative path - Validates the resolved path exists on disk - Raises `LookupError` if addon not registered, `FileNotFoundError` if path missing - **__init__.py** — Exports `addon_resource` ## Usage ```python import kindred_sdk as sdk icon = sdk.addon_resource("silo", "icons/silo_commit.svg") # -> "/path/to/mods/silo/freecad/icons/silo_commit.svg" # Works for any registered addon template = sdk.addon_resource("gears", "data/defaults.json") ``` Replaces fragile `os.path.dirname(__file__)` patterns scattered across addons. Closes #389
forbes added 1 commit 2026-03-04 19:46:49 +00:00
feat(sdk): addon asset path resolution — addon_resource() (#389)
Some checks are pending
Build and Test / build (pull_request) Waiting to run
85ae0effc9
Add kindred_sdk.addon_resource(name, relative_path) that resolves
bundled asset paths relative to an addon's root directory. Looks up
the addon manifest from AddonRegistry for the install root, joins
the relative path, and validates existence on disk.

Raises LookupError if the addon is not registered, FileNotFoundError
if the resolved path does not exist.

Closes #389
forbes merged commit 844dab8875 into main 2026-03-04 19:47:50 +00:00
forbes deleted branch feat/sdk-addon-resource 2026-03-04 19:47:51 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/create#401