if not os.path.exists(tzpath):
continue
with open(tzpath, 'rt') as tzfile:
- data = tzfile.readlines()
-
- for line in data:
- # Look for the ZONE= setting.
- match = zone_re.match(line)
- if match is None:
- # No ZONE= setting. Look for the TIMEZONE= setting.
- match = timezone_re.match(line)
- if match is not None:
- # Some setting existed
- line = line[match.end():]
- etctz = line[:end_re.search(line).start()]
-
- # We found a timezone
- return pytz.timezone(etctz.replace(' ', '_'))
+ for line in tzfile:
+ # Look for the ZONE= setting.
+ match = zone_re.match(line)
+ if match is None:
+ # No ZONE= setting. Look for the TIMEZONE= setting.
+ match = timezone_re.match(line)
+ if match is not None:
+ # Some setting existed
+ line = line[match.end():]
+ etctz = line[:end_re.search(line).start()]
+
+ # We found a timezone
+ return pytz.timezone(etctz.replace(' ', '_'))
# No explicit setting existed. Use localtime
for filename in ('etc/localtime', 'usr/local/etc/localtime'):
units found in it to the `Catalog` supplied to the constructor.
"""
- for lineno, line in enumerate(fileobj.readlines()):
+ for lineno, line in enumerate(fileobj):
line = line.strip()
if not isinstance(line, text_type):
line = line.decode(self.catalog.charset)