2014-09-25 14:18:02 |
mm |
description |
pytz should provide a simple way to set a different 'zoneinfo' directory for the timezone files.
This could be used to switch to the installed OS files or in my case to easier switch zoneinfo versions.
One solution could be to change in the open_resource(name) function in __init__.py the
filename = os.path.join(os.path.dirname(__file__), 'zoneinfo', *name_parts)
to
filename = os.path.join(zoneinfo_dir, *name_parts)
and insert on module level
zoneinfo_dir = os.path.join(os.path.dirname(__file__), 'zoneinfo')
In this way, the user of might
zoneinfo_dir = os.environ.get('TZDATADIR', os.path.join(os.path.dirname(__file__), 'zoneinfo') ) |
pytz should provide a simple way to set a different 'zoneinfo' directory for the timezone files.
This could be used to switch to the installed OS files or in my case to easier switch zoneinfo versions.
One solution could be to change in the open_resource(name) function in __init__.py :
filename = os.path.join(os.path.dirname(__file__), 'zoneinfo', *name_parts)
to
filename = os.path.join(zoneinfo_dir, *name_parts)
and insert on module level
zoneinfo_dir = os.path.join(os.path.dirname(__file__), 'zoneinfo')
In this way, the calling program is able to set the directory to a different one:
import pytz
pytz.zoneinfo_dir = '/usr/share/zoneinfo'
Another option could be to evaluate an environment variable e.g. TZDATADIR and use its string as zoneinfo directory
zoneinfo_dir = os.environ.get('TZDATADIR', os.path.join(os.path.dirname(__file__), 'zoneinfo') )
A change would support the question discussed in
https://answers.launchpad.net/pytz/+question/236068 |
|