Skip to content

Fixes: #19187 - Management command for fetching UN/LOCODE data and regenerating UN_LOCODE values #19316

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

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

Conversation

bctiemann
Copy link
Contributor

Fixes: #19187

This adds a management command, refresh_un_locode.py, which fetches the latest UN/LOCODE data and formats it into the appropriate ChoiceSet tuple to assign to UN_LOCODE.

This is still a draft because:

  • This PR currently only adds the management command, the UN_LOCODE values in un_locode.py have not yet been updated;
  • There are still some values that are encoded strangely. The source files seem to be encoded in Windows-1252/cp1252, and that is how the script treats them; the vast majority of names imported from the Subdivisions file are displayed correctly, but some (particularly in Vietnamese and some others) appear to still be wrong. If I open the CSV files directly on my Mac all the values are interpreted and displayed correctly, so either MacOS is able to do better on-the-fly encoding detection than chardet or Python's csv module can do, or there is some yet unknown character encoding that can be used to read the files.

@bctiemann bctiemann marked this pull request as draft April 24, 2025 19:38
@bctiemann bctiemann requested review from a team, arthanson and jeremystretch and removed request for a team April 24, 2025 19:38
@jeremystretch
Copy link
Member

I'm not sure it makes sense to implement this as a management command. As this functionality is for development purposes only and (presumably) doesn't interact with NetBox data directly, IMO it should be a standalone script.

Copy link
Collaborator

@arthanson arthanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See Jeremy's comment

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.

Wrong UN/LOCODEs in predefined base choice
3 participants