File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33
44def load_tzdata (key ):
5- from importlib . resources import files
5+ from importlib import resources
66
77 components = key .split ("/" )
88 package_name = "." .join (["tzdata.zoneinfo" ] + components [:- 1 ])
99 resource_name = components [- 1 ]
1010
1111 try :
12- return files (package_name ).joinpath (resource_name ).open ('rb' )
12+ return resources . files (package_name ).joinpath (resource_name ).open ("rb" )
1313 except (ImportError , FileNotFoundError , UnicodeEncodeError ):
1414 # There are three types of exception that can be raised that all amount
1515 # to "we cannot find this key":
Original file line number Diff line number Diff line change @@ -111,14 +111,14 @@ def available_timezones():
111111 determine if a given file on the time zone search path is to open it
112112 and check for the "magic string" at the beginning.
113113 """
114- from importlib . resources import files
114+ from importlib import resources
115115
116116 valid_zones = set ()
117117
118118 # Start with loading from the tzdata package if it exists: this has a
119119 # pre-assembled list of zones that only requires opening one file.
120120 try :
121- with files ("tzdata" ).joinpath ("zones" ).open () as f :
121+ with resources . files ("tzdata" ).joinpath ("zones" ).open ("r" ) as f :
122122 for zone in f :
123123 zone = zone .strip ()
124124 if zone :
You can’t perform that action at this time.
0 commit comments