Make language scripts callable from anywhere

This commit is contained in:
heinrich5991 2018-07-25 00:44:49 +02:00
parent 3a8cc43e13
commit 945ea1cf28
4 changed files with 19 additions and 12 deletions

View file

@ -1,6 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import twlang import os
import sys import sys
import twlang
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])) + "/../..")
if len(sys.argv) > 1: if len(sys.argv) > 1:
langs = sys.argv[1:] langs = sys.argv[1:]

View file

@ -1,7 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import twlang import twlang
import os
import sys import sys
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])) + "/../..")
if len(sys.argv) < 3: if len(sys.argv) < 3:
print("usage: python copy_fix.py <infile> <outfile> [--delete-unused] [--append-missing] [--delete-empty]") print("usage: python copy_fix.py <infile> <outfile> [--delete-unused] [--append-missing] [--delete-empty]")
sys.exit() sys.exit()

View file

@ -1,6 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import twlang import os
import sys import sys
import twlang
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])) + "/../..")
if len(sys.argv) < 2: if len(sys.argv) < 2:
print("usage: python find_unchanged.py <file>") print("usage: python find_unchanged.py <file>")

View file

@ -47,20 +47,18 @@ def check_file(path):
def check_folder(path): def check_folder(path):
files = os.listdir(path)
englishlist = set() englishlist = set()
for f in files: for path, _, files in os.walk(path):
newpath = os.path.join(path, f) for f in files:
if os.path.isdir(newpath): if not any(f.endswith(x) for x in ".cpp .c .h".split()):
englishlist.update(check_folder(newpath)) continue
elif os.path.isfile(newpath): englishlist.update(check_file(os.path.join(path, f)))
englishlist.update(check_file(newpath))
return englishlist return englishlist
def languages(): def languages():
index = decode(open("../../data/languages/index.txt"), 2) index = decode(open("data/languages/index.txt"), 2)
langs = {"../"+key+".txt" : [key]+elements for key, elements in index.items()} langs = {"data/languages/"+key+".txt" : [key]+elements for key, elements in index.items()}
return langs return langs
@ -70,5 +68,5 @@ def translations(filename):
def localizes(): def localizes():
englishlist = list(check_folder("../../src")) englishlist = list(check_folder("src"))
return englishlist return englishlist