adafruit / adafruit/Adafruit_CircuitPython_PyPortal
Feature request: Allow json_transforms prior to json_path or image_url_path usage.
- Dominant language
- Python
- Stars
- 46
- Forks
- 56
- PR merge metrics
- No merged PRs in 30d
Description
I have experimented with initializing a PyPortal object using `json_transform=(myTransform),`. Based on debug print statements, the transform function I wrote seems to be called after the `.fetch()` method has completed (or at least at the very end of the `.fetch()` method). I want to be able to edit (transform) the JSON/dict immediately upon it's creation -- before the `image_json_path` (or the `json_path`) is put to use.
For example, I'm trying to adapt the https://learn.adafruit.com/cleveland-museum-of-art-pyportal-frame project to the Art Institute of Chicago's Public API. The Cleveland project uses `image_json_path` to locate a .JPG file to display. For the Art Institute of Chicago, the .JPG location can only be found by concatenating the values from **_two separate_** key:value pairs and a couple of string constants.
I.e., my json_transform would
`json_out["joinedKeys"] = json_out["config"]["iiif_url"] +
"/" +
json_out["data"][0]["imageID"] +
"/full/!320,240/0/default.jpg"`
That would leave me free to initialize the PyPortal object with
`image_json_path = ["joindKeys"],`
I can imagine other use cases for accessing or modifying the JSON/dict data immediately after its creation.
Thank you
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing PyPortal.fetch and the existing json_transform handling, then inspect where image_json_path and json_path are resolved. Done means the transform can modify the fetched JSON/dict before either path is used, including constructing the requested image URL from multiple values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100