annotate scripts/dump_global.py @ 549:423bb50cb8af

use cPickle instead of pickle for better performance (fixes #225) import_cldr on my system was about 20% faster with this patch (13.9 sec vs. 16.9 sec)
author fschwarz
date Sun, 20 Mar 2011 06:01:11 +0000
parents 85e1beadacb0
children
rev   line source
233
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
1 #!/usr/bin/env python
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
2 # -*- coding: utf-8 -*-
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
3 #
530
85e1beadacb0 Update the copyright line.
jruigrok
parents: 233
diff changeset
4 # Copyright (C) 2007-2011 Edgewall Software
233
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
5 # All rights reserved.
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
6 #
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
7 # This software is licensed as described in the file COPYING, which
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
8 # you should have received as part of this distribution. The terms
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
9 # are also available at http://babel.edgewall.org/wiki/License.
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
10 #
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
11 # This software consists of voluntary contributions made by many
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
12 # individuals. For the exact contribution history, see the revision
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
13 # history and logs, available at http://babel.edgewall.org/log/.
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
14
549
423bb50cb8af use cPickle instead of pickle for better performance (fixes #225)
fschwarz
parents: 530
diff changeset
15 import cPickle as pickle
233
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
16 import os
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
17 from pprint import pprint
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
18 import sys
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
19
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
20 import babel
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
21
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
22 dirname = os.path.join(os.path.dirname(babel.__file__))
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
23 filename = os.path.join(dirname, 'global.dat')
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
24 fileobj = open(filename, 'rb')
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
25 try:
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
26 data = pickle.load(fileobj)
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
27 finally:
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
28 fileobj.close()
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
29
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
30 if len(sys.argv) > 1:
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
31 pprint(data.get(sys.argv[1]))
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
32 else:
bc22f5aef216 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents:
diff changeset
33 pprint(data)
Copyright (C) 2012-2017 Edgewall Software