--- /dev/null 2009-06-30 21:35:53.760076206 +0300 +++ dump-tz-db 2009-07-01 04:08:34.027518152 +0300 @@ -0,0 +1,34 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Copyright 2009 TUBITAK/UEKAE +# Licensed under the GNU General Public License, version 2. +# See the file http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt + +# Creates a simple DB for timezone lookups +# Ozan Caglayan 2009 + +import os +import sys +import cPickle +from hashlib import sha1 + + +oldwd = os.getcwd() +os.chdir(sys.argv[1]) + +zones = [] +zonedict = {} +try: + zones = [l.split()[2] for l in open("usr/share/zoneinfo/zone.tab", "r").readlines() if l and not l.startswith("#")] +except IOError: + pass +else: + for zone in zones: + zonedict[sha1(open("usr/share/zoneinfo/%s" % zone, "r").read()).hexdigest()] = zone + + if zonedict: + cp = cPickle.Pickler(open("usr/share/zoneinfo/zoneinfo.dict", "wb"), protocol=2) + cp.dump(zonedict) + +os.chdir(oldwd)