From 85a15fe4425e5becc437d087235bb0bba620e585 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Tue, 3 Jul 2018 16:43:34 -0300 Subject: [PATCH] Port lang scripts to Python3 --- data/languages/scripts/analyze.py | 4 ++-- data/languages/scripts/copy_fix.py | 4 ++-- data/languages/scripts/find_unchanged.py | 4 ++-- data/languages/scripts/twlang.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/data/languages/scripts/analyze.py b/data/languages/scripts/analyze.py index 3f934fdc9..3fa2d628f 100755 --- a/data/languages/scripts/analyze.py +++ b/data/languages/scripts/analyze.py @@ -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: diff --git a/data/languages/scripts/copy_fix.py b/data/languages/scripts/copy_fix.py index eb9261a60..8e4f40408 100755 --- a/data/languages/scripts/copy_fix.py +++ b/data/languages/scripts/copy_fix.py @@ -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: diff --git a/data/languages/scripts/find_unchanged.py b/data/languages/scripts/find_unchanged.py index 53a344b27..561d6f4b9 100755 --- a/data/languages/scripts/find_unchanged.py +++ b/data/languages/scripts/find_unchanged.py @@ -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) diff --git a/data/languages/scripts/twlang.py b/data/languages/scripts/twlang.py index cc69fce30..9a49539cd 100644 --- a/data/languages/scripts/twlang.py +++ b/data/languages/scripts/twlang.py @@ -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