105
by Stuart Bishop
Generate .pot file |
1 |
import sys |
2 |
import os.path |
|
3 |
import time |
|
4 |
from gen_tzinfo import allzones |
|
5 |
||
6 |
from pytz import __version__ |
|
7 |
||
8 |
boilerplate = r"""msgid "" |
|
9 |
msgstr ""
|
|
10 |
"Project-Id-Version: pytz %s\n" |
|
11 |
"POT-Creation-Date: %s\n" |
|
12 |
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13 |
||
14 |
""" % ( |
|
15 |
__version__, |
|
16 |
time.strftime('%Y-%m-%d %H:%M+UTC', time.gmtime(time.time())) |
|
17 |
)
|
|
18 |
||
19 |
def main(): |
|
20 |
assert len(sys.argv) == 2, 'Output file not specified on command line' |
|
21 |
pot_file_name = sys.argv[1] |
|
22 |
||
23 |
if not os.path.exists(os.path.dirname(pot_file_name)): |
|
24 |
os.makedirs(os.path.dirname(pot_file_name)) |
|
25 |
||
26 |
pot = open(pot_file_name, 'wb') |
|
27 |
||
28 |
print >> pot, boilerplate |
|
29 |
||
30 |
for zone in allzones(): |
|
31 |
print >> pot, 'msgid "%s"' % zone |
|
32 |
print >> pot, 'msgstr ""' |
|
33 |
print >> pot |
|
34 |
||
35 |
||
36 |
if __name__ == '__main__': |
|
37 |
main() |