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
import twlang
import os
import sys
import twlang
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])) + "/../..")
if len(sys.argv) > 1:
langs = sys.argv[1:]

View file

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

View file

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

View file

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