Port lang scripts to Python3

This commit is contained in:
Rafael Fontenelle 2018-07-03 16:43:34 -03:00
parent af2d86765c
commit 85a15fe442
4 changed files with 8 additions and 8 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import twlang
import sys
@ -13,7 +13,7 @@ for lang in langs:
empty = 0
supported = 0
unused = 0
for tran, (_, expr, _) in trans.iteritems():
for tran, (_, expr, _) in trans.items():
if not expr:
empty += 1
else:

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import twlang
import sys
@ -28,7 +28,7 @@ if delete_unused or append_missing:
local = twlang.localizes()
if append_missing:
supported = []
for tran, (start, expr, end) in trans.iteritems():
for tran, (start, expr, end) in trans.items():
if delete_unused and tran not in local:
content[start:end] = [None]*(end-start)
if append_missing and tran in local:

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import twlang
import sys
@ -8,6 +8,6 @@ if len(sys.argv) < 2:
infile = sys.argv[1]
trans = twlang.translations(infile)
for tran, (_, expr, _) in trans.iteritems():
for tran, (_, expr, _) in trans.items():
if tran == expr:
print(tran)

View file

@ -12,7 +12,7 @@ def decode(fileobj, elements_per_key):
data = {}
current_key = None
for index, line in enumerate(fileobj):
line = line.decode("utf-8-sig").encode("utf-8")
line = line.encode("utf-8").decode("utf-8-sig")
line = line[:-1]
if line and line[-1] == "\r":
line = line[:-1]
@ -60,7 +60,7 @@ def check_folder(path):
def languages():
index = decode(open("../index.txt"), 2)
langs = {"../"+key+".txt" : [key]+elements for key, elements in index.iteritems()}
langs = {"../"+key+".txt" : [key]+elements for key, elements in index.items()}
return langs