1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/usr/bin/python
import os
import sys
if sys.argv[1] == "-h" or sys.argv[1] == "--help":
print "Purpose:"
print "Outputs all msgids from pot file named as argument. All else in pot file deleted. Used by diff_msgids to see whether the set of translatable strings have changed.\n"
print "Usage: get_msgids <pot>\n"
sys.exit(1)
if len(sys.argv) < 2:
print "missing args, quitting."
sys.exit(1)
fin_n = sys.argv[1]
fin = open(fin_n, "r")
f_lines = fin.readlines()
fin.close()
f_lines_clean = []
for line in f_lines:
if line.endswith("\n"): line = line[:len(line)-1]
if not line.startswith("#") and not line.startswith(" ") and not line.startswith("\n") and not line.startswith("\r"):
f_lines_clean.append(line)
index = -1
inmsgid = False
msgid = ""
msgids = []
#f_lines_clean.sort()
#print str(sorted(f_lines_clean))
for line in f_lines_clean:
index += 1
if line.startswith("msgid"):
inmsgid = True
if line.startswith("msgstr"):
inmsgid = False
# msgid += "\n"
print msgid
msgids.append(msgid)
msgid = ""
if inmsgid:
msgid += line
if msgid.endswith("\n"):
msgid=msgid[:len(msgid)-1]
sys.exit(0)
|