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

feat: fetch languages.json from the GH repository #36

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Nanush7
Copy link
Member

@Nanush7 Nanush7 commented Jan 10, 2025

The WST won't need to deploy the compiler to PyPI every time we want to change the languages.json file. The file will be fetched from GitHub (main branch), from https://raw.githubusercontent.com/thewca/wca-regulations-compiler/main/wrc/data/languages.json.

Considerations:

  • I wasn't sure whether to use the requests library (which I have used before) or the built-in urllib.requests library. I chose the latter because it's built-in and works perfectly fine for what we need.
  • Redirects are handled by urllib automatically. Do we have any issues with allowing redirects?
  • The fallback file will be used only if urllib raises HTTPError (e.g. 4xx HTTP errors) or URLError (e.g. on timeout), but not if the fetched JSON cannot be parsed. In that case, the execution will be aborted when trying to parse the contents of the response. I'm doing it like this because getting an invalid JSON from the repo would be a significant issue that should be checked. I can also make it use the fallback in this case if required.

Edit: I'll bump the version in a different PR.

@Nanush7 Nanush7 requested a review from gregorbg January 10, 2025 01:32
@Nanush7 Nanush7 self-assigned this Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant