[PR #19316] [CLOSED] Fixes: #19187 - Management command for fetching UN/LOCODE data and regenerating UN_LOCODE values #15609

Closed
opened 2025-12-30 00:22:59 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/19316
Author: @bctiemann
Created: 4/24/2025
Status: Closed

Base: mainHead: 19187-un_locodes-import-management-command


📝 Commits (2)

  • 17384c5 Management command for fetching UN/LOCODE data and regenerating the values for UN_LOCODE ChoiceSet
  • c370c9c Generated updates for UN_LOCODE

📊 Changes

2 files changed (+69468 additions, -64808 deletions)

View changed files

📝 netbox/extras/data/un_locode.py (+69393 -64808)
netbox/extras/management/commands/refresh_un_locode.py (+75 -0)

📄 Description

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/19316 **Author:** [@bctiemann](https://github.com/bctiemann) **Created:** 4/24/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `19187-un_locodes-import-management-command` --- ### 📝 Commits (2) - [`17384c5`](https://github.com/netbox-community/netbox/commit/17384c524eb6afe9a59927d126a4af0194e5bb38) Management command for fetching UN/LOCODE data and regenerating the values for UN_LOCODE ChoiceSet - [`c370c9c`](https://github.com/netbox-community/netbox/commit/c370c9ca8410deb1f45d20a0852a10ecca151afa) Generated updates for UN_LOCODE ### 📊 Changes **2 files changed** (+69468 additions, -64808 deletions) <details> <summary>View changed files</summary> 📝 `netbox/extras/data/un_locode.py` (+69393 -64808) ➕ `netbox/extras/management/commands/refresh_un_locode.py` (+75 -0) </details> ### 📄 Description ### 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:22:59 +01:00
adam closed this issue 2025-12-30 00:22:59 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15609