From d981a836526701bc151bf2b6ebe076642f3ad19c Mon Sep 17 00:00:00 2001 From: SDE Date: Fri, 12 Jul 2024 19:01:58 +0300 Subject: [PATCH] 1.6.1 parsing timezones --- ReferenceDataApp/funcs.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ReferenceDataApp/funcs.py b/ReferenceDataApp/funcs.py index 1f8ba8a..b779620 100644 --- a/ReferenceDataApp/funcs.py +++ b/ReferenceDataApp/funcs.py @@ -213,7 +213,8 @@ def parse_data(): geo_lat = float(city_Dict['@lat']) geo_lon = float(city_Dict['@lon']) tz = tzf.timezone_at(lng=geo_lon, lat=geo_lat) - print(f'city {city_Dict["name:en"]} - {tz}') + if not city or not city.timezone: + print(f'city {city_Dict["name:en"]} - {tz}') # собираем данные city_kwargs = { @@ -256,11 +257,12 @@ def parse_data(): hash_data = hashlib.md5(json.dumps(country_Dict, sort_keys=True, ensure_ascii=True).encode('utf-8')).hexdigest() country.add_node_to_json_data({'hash': hash_data}) - country.timezone = tzf.timezone_at(lng=float(country.geo_lon), lat=float(country.geo_lat)) - print(f'country {country.name} - {country.timezone}') + if not country.timezone: + country.timezone = tzf.timezone_at(lng=float(country.geo_lon), lat=float(country.geo_lat)) + print(f'country {country.name} - {country.timezone}') if 'parsing_status' in country_Dict and country_Dict['parsing_status'] == 'finished': country.parsing_finished_DT = datetime.now() - country.save(update_fields=['parsing_finished_DT']) + country.save() return True \ No newline at end of file