forked from nicotine-plus/nicotine-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtr_gen
executable file
·56 lines (51 loc) · 1.87 KB
/
tr_gen
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
52
53
54
55
56
#!/usr/bin/python
# Old Script fails on imagedata.py and icondata.py
# cp nicotine nicotine.py
# xgettext -k_ -kN_ -o languages/nicotine.pot *.py */*.py */*/*.py
# rm nicotine.py
print "Generating nicotine.pot from selected python scripts in this directory, and subdirectories"
import sys, os
import shutil
files = {}
files[""] = os.listdir("./")
files["pynicotine/"] = os.listdir("./pynicotine")
files["pynicotine/gtkgui/"] = os.listdir("./pynicotine/gtkgui")
if not os.path.exists("./nicotine.py"):
print "Error: nicotine executable not found in this directory"
raise SystemExit
def isPythonScript(dir, file):
if file.rsplit(".")[-1].lower() in ("py"):
return dir + file
return None
def isGlade(dir, file):
if file.rsplit(".")[-1].lower() in ("glade"):
return dir + file
return None
pythonscripts = []
gladescripts = []
blacklist = ["icondata", "imagedata", "__init__"]
for dir, files in files.items():
for file in files:
ispy = isPythonScript(dir, file)
if ispy is not None:
pythonscripts.append(ispy)
isglade = isGlade(dir, file)
if isglade is not None:
gladescripts.append(isglade)
for item in blacklist:
for path in pythonscripts[:]:
if item in path:
pythonscripts.remove(path)
goodpython = ""
for path in pythonscripts[:]:
goodpython += path + " "
print "xgettext --no-location -k_ -kN_ -o languages/nicotine-python.pot %s" % goodpython
r = os.system("xgettext --no-location -k_ -kN_ -o languages/nicotine-python.pot %s" % goodpython)
gladestring = ""
for path in gladescripts[:]:
gladestring += path + " "
print "xgettext --no-location -k_ -kN_ -L Glade -o languages/nicotine-glade.pot %s" % gladestring
r = os.system("xgettext --no-location -k_ -kN_ -L Glade -o languages/nicotine-glade.pot %s" % gladestring)
r = os.system("msgcat languages/nicotine-glade.pot languages/nicotine-python.pot -o languages/nicotine.pot")
if r:
print "Error while creating nicotine.pot"