From 7b13d749b2502bc917cef65af4e71e81eaf5c99f Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Thu, 9 May 2024 23:36:32 +0000 Subject: [PATCH] Add QA check for valid time zones Make sure every WX weather zone has an accompanying time zone and that its value is a valid entry from the local TZDB. --- weather.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/weather.py b/weather.py index 17a0e12..6b42a84 100644 --- a/weather.py +++ b/weather.py @@ -1239,7 +1239,7 @@ def gecos(formatted): return tuple(coordinates) def correlate(): - import codecs, csv, datetime, hashlib, os, re, sys, time, zipfile + import codecs, csv, datetime, hashlib, os, re, sys, time, zipfile, zoneinfo if pyversion("3"): import configparser else: import ConfigParser as configparser for filename in os.listdir("."): @@ -2138,6 +2138,7 @@ def correlate(): zctas_nocentroid += 1 zones_nocentroid = 0 zones_nodescription = 0 + zones_notz = 0 zones_noforecast = 0 zones_overlapping = 0 zonetable = {} @@ -2165,6 +2166,10 @@ def correlate(): if not zones.has_option(zone, "description"): qalog.append("%s: no description\n" % zone) zones_nodescription += 1 + if not zones.has_option(zone, "tz") or not zones.get( + zone, "tz") in zoneinfo.available_timezones(): + qalog.append("%s: no time zone\n" % zone) + zones_notz += 1 if not zones.has_option(zone, "zone_forecast"): qalog.append("%s: no forecast\n" % zone) zones_noforecast += 1 @@ -2201,6 +2206,8 @@ def correlate(): print(" %s zones with no centroid"%zones_nocentroid) if zones_nodescription: print(" %s zones with no description"%zones_nodescription) + if zones_notz: + print(" %s zones with no time zone"%zones_notz) if zones_noforecast: print(" %s zones with no forecast"%zones_noforecast) if zones_overlapping: -- 2.11.0