A continuation of HomeBox the inventory and organization system built for the Home User
Update update_currencies.py
Katos67668578e8f5
diff --git a/.github/scripts/update_currencies.py b/.github/scripts/update_currencies.pyindex 51daf822..a7cd58f1 100644--- a/.github/scripts/update_currencies.py+++ b/.github/scripts/update_currencies.py@@ -4,11 +4,8 @@ import osdef fetch_currencies():try:- response = requests.get('https://restcountries.com/v3.1/all')+ response = requests.get('https://restcountries.com/v3.1/all?fields=name,common,currencies')response.raise_for_status()- except requests.exceptions.Timeout:- print("Request to the API timed out.")- return []except requests.exceptions.RequestException as e:print(f"An error occurred while making the request: {e}")return []@@ -35,10 +32,12 @@ def fetch_currencies():return currencies_listdef save_currencies(currencies, file_path):+ # Sort the list by the "local" field+ sorted_currencies = sorted(currencies, key=lambda x: x['local'].lower() if x['local'] else "")try:os.makedirs(os.path.dirname(file_path), exist_ok=True)with open(file_path, 'w', encoding='utf-8') as f:- json.dump(currencies, f, ensure_ascii=False, indent=4)+ json.dump(sorted_currencies, f, ensure_ascii=False, indent=4)except IOError as e:print(f"An error occurred while writing to the file: {e}")@@ -62,4 +61,4 @@ def main():print("Currencies updated and saved.")if __name__ == "__main__":- main()\ No newline at end of file+ main()