diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2022-03-27 12:56:34 +0200 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2022-03-27 12:56:34 +0200 |
commit | 493dce212d925dd7c1422813daaa95cf36521f93 (patch) | |
tree | f18cfa561e91ab40dbcdf868680262a3e9bdcf24 /utils | |
parent | aaf0f1c371c544e666f30682b22098475938bd07 (diff) | |
download | rockbox-493dce212d925dd7c1422813daaa95cf36521f93.tar.gz rockbox-493dce212d925dd7c1422813daaa95cf36521f93.zip |
rbutil: Fix langstat script.
Change-Id: I323b0e8dbf87f1d53881f5b89f26c5906796fde4
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/rbutilqt/langstats.py | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/utils/rbutilqt/langstats.py b/utils/rbutilqt/langstats.py index cbf49dce08..26a56f866c 100755 --- a/utils/rbutilqt/langstats.py +++ b/utils/rbutilqt/langstats.py | |||
@@ -53,7 +53,7 @@ LANGS = { | |||
53 | } | 53 | } |
54 | 54 | ||
55 | 55 | ||
56 | LANGBASE = "rbutil/rbutilqt/" | 56 | LANGBASE = "utils/rbutilqt" |
57 | # Paths and files to retrieve from svn. | 57 | # Paths and files to retrieve from svn. |
58 | # This is a mixed list, holding both paths and filenames. | 58 | # This is a mixed list, holding both paths and filenames. |
59 | # Get cpp sources as well for lupdate to work. | 59 | # Get cpp sources as well for lupdate to work. |
@@ -75,24 +75,26 @@ def main(): | |||
75 | def langstat(pretty=True, tree=None): | 75 | def langstat(pretty=True, tree=None): |
76 | '''Get translation stats and print to stdout.''' | 76 | '''Get translation stats and print to stdout.''' |
77 | # get gitpaths to temporary folder | 77 | # get gitpaths to temporary folder |
78 | workfolder = tempfile.mkdtemp() + "/" | 78 | workfolder = tempfile.mkdtemp() |
79 | repo = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) | 79 | repo = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) |
80 | if tree is None: | 80 | if tree is None: |
81 | tree = gitscraper.get_refs(repo)['HEAD'] | 81 | tree = gitscraper.get_refs(repo)['HEAD'] |
82 | filesprops = gitscraper.scrape_files( | 82 | filesprops = gitscraper.scrape_files( |
83 | repo, tree, GITPATHS, dest=workfolder, | 83 | repo, tree, GITPATHS, dest=workfolder, |
84 | timestamp_files=["rbutil/rbutilqt/lang"]) | 84 | timestamp_files=[f"{LANGBASE}/lang"]) |
85 | 85 | ||
86 | projectfolder = workfolder + LANGBASE | 86 | projectfolder = os.path.join(workfolder, LANGBASE) |
87 | # lupdate translations and drop all obsolete translations | 87 | # lupdate translations and drop all obsolete translations |
88 | subprocess.Popen(["lupdate", "-no-obsolete", "rbutilqt.pro"], | 88 | subprocess.Popen(["lupdate", "-no-obsolete", projectfolder, "-ts"] |
89 | + [f"lang/rbutil_{l}.ts" for l in LANGS], | ||
89 | stdout=subprocess.PIPE, stderr=subprocess.PIPE, | 90 | stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
90 | cwd=projectfolder).communicate() | 91 | cwd=projectfolder).communicate() |
91 | # lrelease translations to get status | 92 | # lrelease translations to get status |
92 | output = subprocess.Popen(["lrelease", "rbutilqt.pro"], | 93 | output = subprocess.Popen(["lrelease"] |
94 | + [f"lang/rbutil_{l}.ts" for l in LANGS], | ||
93 | stdout=subprocess.PIPE, stderr=subprocess.PIPE, | 95 | stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
94 | cwd=projectfolder).communicate() | 96 | cwd=projectfolder).communicate() |
95 | lines = re.split(r"\n", output[0].decode()) | 97 | lines = output[0].decode().split("\n") |
96 | 98 | ||
97 | re_updating = re.compile(r"^Updating.*") | 99 | re_updating = re.compile(r"^Updating.*") |
98 | re_generated = re.compile(r"Generated.*") | 100 | re_generated = re.compile(r"Generated.*") |
@@ -124,9 +126,8 @@ def langstat(pretty=True, tree=None): | |||
124 | print(head) | 126 | print(head) |
125 | print(delim) | 127 | print(delim) |
126 | else: | 128 | else: |
127 | rev = "%s (%s)" % ( | 129 | rev = f"{tree} {gitscraper.get_file_timestamp(repo, tree, '.')}" |
128 | tree, gitscraper.get_file_timestamp(repo, tree, ".")) | 130 | print(f"| *Translation status as of revision {rev}* ||||||||") |
129 | print("| *Translation status as of revision %s* ||||||||" % rev) | ||
130 | print("| *Language* | *Language Code* | *Translations* " | 131 | print("| *Language* | *Language Code* | *Translations* " |
131 | "| *Finished* | *Unfinished* | *Untranslated* | *Updated* " | 132 | "| *Finished* | *Unfinished* | *Untranslated* | *Updated* " |
132 | "| *Done* |") | 133 | "| *Done* |") |
@@ -135,7 +136,7 @@ def langstat(pretty=True, tree=None): | |||
135 | for i, line in enumerate(lines): | 136 | for i, line in enumerate(lines): |
136 | if re_updating.search(line): | 137 | if re_updating.search(line): |
137 | lang = re_qmlang.findall(line) | 138 | lang = re_qmlang.findall(line) |
138 | tsfile = "rbutil/rbutilqt/lang/%s.ts" % re_qmbase.findall(line)[0] | 139 | tsfile = f"{LANGBASE}/lang/{re_qmbase.findall(line)[0]}.ts" |
139 | tsdate = filesprops[1][tsfile] | 140 | tsdate = filesprops[1][tsfile] |
140 | 141 | ||
141 | line = lines[i + 1] | 142 | line = lines[i + 1] |
@@ -166,11 +167,10 @@ def langstat(pretty=True, tree=None): | |||
166 | else: | 167 | else: |
167 | fancylang = lang[0] | 168 | fancylang = lang[0] |
168 | if pretty: | 169 | if pretty: |
169 | print(("| {:%i} | {:5} | {:3} | {:3} | {:3} | {:3} | {:25} | " | 170 | print(f"| {name:{titlemax}} | {fancylang:5} | " |
170 | "{:3}%% {} |" | 171 | f"{translations:3} | {finished:3} | {unfinished:3} | " |
171 | % titlemax).format( | 172 | f"{ignored:3} | {tsdate:25} | " |
172 | name, fancylang, translations, finished, unfinished, | 173 | f"{int(percent):3}% {progress} |") |
173 | ignored, tsdate, int(percent), progress)) | ||
174 | else: | 174 | else: |
175 | if percent > 90: | 175 | if percent > 90: |
176 | color = r'%GREEN%' | 176 | color = r'%GREEN%' |
@@ -180,10 +180,9 @@ def langstat(pretty=True, tree=None): | |||
180 | else: | 180 | else: |
181 | color = r'%RED%' | 181 | color = r'%RED%' |
182 | 182 | ||
183 | print("| %s | %s | %s | %s | %s | %s | %s | %s %i%% " | 183 | print(f"| {name} | {fancylang} | {translations} | {finished} " |
184 | "%%ENDCOLOR%% %s |" % | 184 | f"| {unfinished} | {ignored} | {tsdate} | {color} " |
185 | (name, fancylang, translations, finished, unfinished, | 185 | f"{percent:.1f}% %ENDCOLOR% {progress} |") |
186 | ignored, tsdate, color, percent, progress)) | ||
187 | 186 | ||
188 | if pretty: | 187 | if pretty: |
189 | print(delim) | 188 | print(delim) |