add-dump-tz-db-script.patch 997 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. --- /dev/null 2009-06-30 21:35:53.760076206 +0300
  2. +++ dump-tz-db 2009-07-01 04:08:34.027518152 +0300
  3. @@ -0,0 +1,34 @@
  4. +#!/usr/bin/python
  5. +# -*- coding: utf-8 -*-
  6. +#
  7. +# Copyright 2009 TUBITAK/UEKAE
  8. +# Licensed under the GNU General Public License, version 2.
  9. +# See the file http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
  10. +
  11. +# Creates a simple DB for timezone lookups
  12. +# Ozan Caglayan <ozan_at_pardus.org.tr> 2009
  13. +
  14. +import os
  15. +import sys
  16. +import cPickle
  17. +from hashlib import sha1
  18. +
  19. +
  20. +oldwd = os.getcwd()
  21. +os.chdir(sys.argv[1])
  22. +
  23. +zones = []
  24. +zonedict = {}
  25. +try:
  26. + zones = [l.split()[2] for l in open("usr/share/zoneinfo/zone.tab", "r").readlines() if l and not l.startswith("#")]
  27. +except IOError:
  28. + pass
  29. +else:
  30. + for zone in zones:
  31. + zonedict[sha1(open("usr/share/zoneinfo/%s" % zone, "r").read()).hexdigest()] = zone
  32. +
  33. + if zonedict:
  34. + cp = cPickle.Pickler(open("usr/share/zoneinfo/zoneinfo.dict", "wb"), protocol=2)
  35. + cp.dump(zonedict)
  36. +
  37. +os.chdir(oldwd)