Commit 5e4af47e by William Tisäter

Optimize and refactor internal seek functions

parent e0a63175
......@@ -362,11 +362,16 @@ CITY_EDITION_REV0 = 6
CITY_EDITION_REV1 = 2
ORG_EDITION = 5
ISP_EDITION = 4
PROXY_EDITION = 8
ASNUM_EDITION = 9
# Not yet supported databases
PROXY_EDITION = 8
NETSPEED_EDITION = 11
COUNTRY_EDITION_V6 = 12
# Collection of databases
CITY_EDITIONS = (CITY_EDITION_REV0, CITY_EDITION_REV1)
REGION_EDITIONS = (REGION_EDITION_REV0, REGION_EDITION_REV1)
SEGMENT_RECORD_LENGTH = 3
STANDARD_RECORD_LENGTH = 3
ORG_RECORD_LENGTH = 4
......
......@@ -699,17 +699,17 @@ _country["ZW"] = "Africa/Harare"
def time_zone_by_country_and_region(country_code, region_name=None):
if country_code not in _country:
return None
return ''
if not region_name or region_name == '00':
region_name = None
timezones = _country[country_code]
if isinstance(timezones, str):
return timezones
if region_name:
return timezones.get(region_name)
if not region_name:
return ''
return timezones.get(region_name)
......@@ -40,7 +40,8 @@ class TestGeoIPCityFunctions(unittest.TestCase):
'longitude': -0.23339999999998895,
'country_code3': 'GBR',
'latitude': 51.283299999999997,
'postal_code': None, 'dma_code': 0,
'postal_code': '',
'dma_code': 0,
'country_code': 'GB',
'country_name': 'United Kingdom',
'time_zone': 'Europe/London'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment