forked from len0rd/rockbox
langstat: improve code style a bit.
Change-Id: Ide53de01282fa49640e490a02a6e20abf4d6605a
This commit is contained in:
parent
89afa32584
commit
3dcf833edd
1 changed files with 18 additions and 19 deletions
|
|
@ -22,7 +22,6 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import string
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
@ -33,7 +32,7 @@ sys.path.append(os.path.abspath(os.path.join(
|
||||||
import gitscraper
|
import gitscraper
|
||||||
|
|
||||||
|
|
||||||
langs = {
|
LANGS = {
|
||||||
'cs': 'Czech',
|
'cs': 'Czech',
|
||||||
'de': 'German',
|
'de': 'German',
|
||||||
'fi': 'Finnish',
|
'fi': 'Finnish',
|
||||||
|
|
@ -53,11 +52,11 @@ langs = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
langbase = "rbutil/rbutilqt/"
|
LANGBASE = "rbutil/rbutilqt/"
|
||||||
# Paths and files to retrieve from svn.
|
# Paths and files to retrieve from svn.
|
||||||
# This is a mixed list, holding both paths and filenames.
|
# This is a mixed list, holding both paths and filenames.
|
||||||
# Get cpp sources as well for lupdate to work.
|
# Get cpp sources as well for lupdate to work.
|
||||||
gitpaths = [langbase]
|
GITPATHS = [LANGBASE]
|
||||||
|
|
||||||
|
|
||||||
def printhelp():
|
def printhelp():
|
||||||
|
|
@ -78,16 +77,19 @@ def main():
|
||||||
pretty = True
|
pretty = True
|
||||||
else:
|
else:
|
||||||
pretty = False
|
pretty = False
|
||||||
|
langstat(pretty)
|
||||||
|
|
||||||
|
|
||||||
|
def langstat(pretty=True):
|
||||||
# get gitpaths to temporary folder
|
# get gitpaths to temporary folder
|
||||||
workfolder = tempfile.mkdtemp() + "/"
|
workfolder = tempfile.mkdtemp() + "/"
|
||||||
repo = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
|
repo = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
|
||||||
tree = gitscraper.get_refs(repo)['refs/remotes/origin/master']
|
tree = gitscraper.get_refs(repo)['refs/remotes/origin/master']
|
||||||
filesprops = gitscraper.scrape_files(
|
filesprops = gitscraper.scrape_files(
|
||||||
repo, tree, gitpaths, dest=workfolder,
|
repo, tree, GITPATHS, dest=workfolder,
|
||||||
timestamp_files=["rbutil/rbutilqt/lang"])
|
timestamp_files=["rbutil/rbutilqt/lang"])
|
||||||
|
|
||||||
projectfolder = workfolder + langbase
|
projectfolder = workfolder + LANGBASE
|
||||||
# lupdate translations and drop all obsolete translations
|
# lupdate translations and drop all obsolete translations
|
||||||
subprocess.Popen(["lupdate-qt4", "-no-obsolete", "rbutilqt.pro"],
|
subprocess.Popen(["lupdate-qt4", "-no-obsolete", "rbutilqt.pro"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||||
|
|
@ -109,16 +111,15 @@ def main():
|
||||||
|
|
||||||
# print header
|
# print header
|
||||||
titlemax = 0
|
titlemax = 0
|
||||||
for l in langs:
|
for lang in LANGS:
|
||||||
cur = len(langs[l])
|
cur = len(LANGS[lang])
|
||||||
if titlemax < cur:
|
if titlemax < cur:
|
||||||
titlemax = cur
|
titlemax = cur
|
||||||
|
|
||||||
if pretty:
|
if pretty:
|
||||||
spaces = [7, 5, 5, 5, 5, 27, 17]
|
|
||||||
delim = "+--" + titlemax * "-"
|
delim = "+--" + titlemax * "-"
|
||||||
for s in spaces:
|
for spc in [7, 5, 5, 5, 5, 27, 17]:
|
||||||
delim += "+" + "-" * s
|
delim += "+" + "-" * spc
|
||||||
delim += "+"
|
delim += "+"
|
||||||
head = ("| {:%s} | {:6}|{:5}|{:5}|{:5}|{:5}| {:26}| {:16}|"
|
head = ("| {:%s} | {:6}|{:5}|{:5}|{:5}|{:5}| {:26}| {:16}|"
|
||||||
% titlemax).format("Language", "Code", "Trans", "Fin", "Unfin",
|
% titlemax).format("Language", "Code", "Trans", "Fin", "Unfin",
|
||||||
|
|
@ -129,16 +130,15 @@ def main():
|
||||||
print(head)
|
print(head)
|
||||||
print(delim)
|
print(delim)
|
||||||
else:
|
else:
|
||||||
r = "%s (%s)" % (str(tree),
|
rev = "%s (%s)" % (
|
||||||
gitscraper.get_file_timestamp(repo, tree, "."))
|
tree, gitscraper.get_file_timestamp(repo, tree, "."))
|
||||||
print("| *Translation status as of revision %s* ||||||||" % r)
|
print("| *Translation status as of revision %s* ||||||||" % rev)
|
||||||
print("| *Language* | *Language Code* | *Translations* "
|
print("| *Language* | *Language Code* | *Translations* "
|
||||||
"| *Finished* | *Unfinished* | *Untranslated* | *Updated* "
|
"| *Finished* | *Unfinished* | *Untranslated* | *Updated* "
|
||||||
"| *Done* |")
|
"| *Done* |")
|
||||||
|
|
||||||
# scan output
|
# scan output
|
||||||
i = 0
|
for i in range(len(lines)):
|
||||||
while i < len(lines):
|
|
||||||
line = lines[i]
|
line = lines[i]
|
||||||
if re_updating.search(line):
|
if re_updating.search(line):
|
||||||
lang = re_qmlang.findall(line)
|
lang = re_qmlang.findall(line)
|
||||||
|
|
@ -158,8 +158,8 @@ def main():
|
||||||
ignored = int(re_ignout.findall(line)[0])
|
ignored = int(re_ignout.findall(line)[0])
|
||||||
else:
|
else:
|
||||||
ignored = 0
|
ignored = 0
|
||||||
if lang[0] in langs:
|
if lang[0] in LANGS:
|
||||||
name = langs[lang[0]].strip()
|
name = LANGS[lang[0]].strip()
|
||||||
else:
|
else:
|
||||||
name = '(unknown)'
|
name = '(unknown)'
|
||||||
|
|
||||||
|
|
@ -191,7 +191,6 @@ def main():
|
||||||
"%%ENDCOLOR%% %s |" %
|
"%%ENDCOLOR%% %s |" %
|
||||||
(name, fancylang, translations, finished, unfinished,
|
(name, fancylang, translations, finished, unfinished,
|
||||||
ignored, tsdate, color, percent, bar))
|
ignored, tsdate, color, percent, bar))
|
||||||
i += 1
|
|
||||||
|
|
||||||
if pretty:
|
if pretty:
|
||||||
print(delim)
|
print(delim)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue