Skip to content

Commit

Permalink
lazy timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
eendebakpt committed Nov 6, 2022
1 parent 4ebc28d commit 5e9f112
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gen_tzinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ def add_allzones(filename):
cz.append(zone)
cz.sort()

print('all_timezones = \\', file=outf)
print('all_timezones_unchecked = \\', file=outf)
pprint(sorted(allzones()), outf)
print('''all_timezones = LazyList(
tz for tz in all_timezones if resource_exists(tz))
tz for tz in all_timezones_unchecked if resource_exists(tz))
''', file=outf)
print('all_timezones_set = LazySet(all_timezones)', file=outf)
# Per lp:1835784 we can't afford to do this at import time
Expand Down
2 changes: 1 addition & 1 deletion src/pytz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def _case_insensitive_zone_lookup(zone):
"""case-insensitively matching timezone, else return zone unchanged"""
global _all_timezones_lower_to_standard
if _all_timezones_lower_to_standard is None:
_all_timezones_lower_to_standard = dict((tz.lower(), tz) for tz in all_timezones) # noqa
_all_timezones_lower_to_standard = dict((tz.lower(), tz) for tz in all_timezones_unchecked) # noqa
return _all_timezones_lower_to_standard.get(zone.lower()) or zone # noqa


Expand Down

0 comments on commit 5e9f112

Please sign in to comment.