Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils.parse_metadata() should be a documented internal function #1405

Closed
simonw opened this issue Jul 28, 2021 · 3 comments
Closed

utils.parse_metadata() should be a documented internal function #1405

simonw opened this issue Jul 28, 2021 · 3 comments

Comments

@simonw
Copy link
Owner

simonw commented Jul 28, 2021

Because it's used by this plugin: https://github.com/simonw/datasette-remote-metadata

@simonw
Copy link
Owner Author

simonw commented Jul 28, 2021

def parse_metadata(content):
# content can be JSON or YAML
try:
return json.loads(content)
except json.JSONDecodeError:
try:
return yaml.safe_load(content)
except yaml.YAMLError:
raise BadMetadataError("Metadata is not valid JSON or YAML")

@simonw
Copy link
Owner Author

simonw commented Jul 28, 2021

Document that it can raise a BadMetadataError exception.

@simonw simonw closed this as completed in 121e10c Jul 29, 2021
@simonw
Copy link
Owner Author

simonw commented Jul 29, 2021

New documentation section for datasette.utils is here: https://docs.datasette.io/en/latest/internals.html#the-datasette-utils-module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant