summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/langstats.py
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2013-09-14 09:36:54 +0200
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2013-09-18 23:37:38 +0200
commit3dcf833edd559509c3258f75958cc39d0d074f83 (patch)
tree37ed9378ba77fa746d354423a785a80c82f48e8f /rbutil/rbutilqt/langstats.py
parent89afa32584f534f89f94c493f915c49dad51539d (diff)
downloadrockbox-3dcf833edd559509c3258f75958cc39d0d074f83.tar.gz
rockbox-3dcf833edd559509c3258f75958cc39d0d074f83.tar.bz2
rockbox-3dcf833edd559509c3258f75958cc39d0d074f83.zip
langstat: improve code style a bit.
Change-Id: Ide53de01282fa49640e490a02a6e20abf4d6605a
Diffstat (limited to 'rbutil/rbutilqt/langstats.py')
-rwxr-xr-xrbutil/rbutilqt/langstats.py37
1 files changed, 18 insertions, 19 deletions
diff --git a/rbutil/rbutilqt/langstats.py b/rbutil/rbutilqt/langstats.py
index 76f47450bd..cb0bb3ffbd 100755
--- a/rbutil/rbutilqt/langstats.py
+++ b/rbutil/rbutilqt/langstats.py
@@ -22,7 +22,6 @@
import subprocess
import re
import sys
-import string
import tempfile
import os
import shutil
@@ -33,7 +32,7 @@ sys.path.append(os.path.abspath(os.path.join(
import gitscraper
-langs = {
+LANGS = {
'cs': 'Czech',
'de': 'German',
'fi': 'Finnish',
@@ -53,11 +52,11 @@ langs = {
}
-langbase = "rbutil/rbutilqt/"
+LANGBASE = "rbutil/rbutilqt/"
# Paths and files to retrieve from svn.
# This is a mixed list, holding both paths and filenames.
# Get cpp sources as well for lupdate to work.
-gitpaths = [langbase]
+GITPATHS = [LANGBASE]
def printhelp():
@@ -78,16 +77,19 @@ def main():
pretty = True
else:
pretty = False
+ langstat(pretty)
+
+def langstat(pretty=True):
# get gitpaths to temporary folder
workfolder = tempfile.mkdtemp() + "/"
repo = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
tree = gitscraper.get_refs(repo)['refs/remotes/origin/master']
filesprops = gitscraper.scrape_files(
- repo, tree, gitpaths, dest=workfolder,
+ repo, tree, GITPATHS, dest=workfolder,
timestamp_files=["rbutil/rbutilqt/lang"])
- projectfolder = workfolder + langbase
+ projectfolder = workfolder + LANGBASE
# lupdate translations and drop all obsolete translations
subprocess.Popen(["lupdate-qt4", "-no-obsolete", "rbutilqt.pro"],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
@@ -109,16 +111,15 @@ def main():
# print header
titlemax = 0
- for l in langs:
- cur = len(langs[l])
+ for lang in LANGS:
+ cur = len(LANGS[lang])
if titlemax < cur:
titlemax = cur
if pretty:
- spaces = [7, 5, 5, 5, 5, 27, 17]
delim = "+--" + titlemax * "-"
- for s in spaces:
- delim += "+" + "-" * s
+ for spc in [7, 5, 5, 5, 5, 27, 17]:
+ delim += "+" + "-" * spc
delim += "+"
head = ("| {:%s} | {:6}|{:5}|{:5}|{:5}|{:5}| {:26}| {:16}|"
% titlemax).format("Language", "Code", "Trans", "Fin", "Unfin",
@@ -129,16 +130,15 @@ def main():
print(head)
print(delim)
else:
- r = "%s (%s)" % (str(tree),
- gitscraper.get_file_timestamp(repo, tree, "."))
- print("| *Translation status as of revision %s* ||||||||" % r)
+ rev = "%s (%s)" % (
+ tree, gitscraper.get_file_timestamp(repo, tree, "."))
+ print("| *Translation status as of revision %s* ||||||||" % rev)
print("| *Language* | *Language Code* | *Translations* "
"| *Finished* | *Unfinished* | *Untranslated* | *Updated* "
"| *Done* |")
# scan output
- i = 0
- while i < len(lines):
+ for i in range(len(lines)):
line = lines[i]
if re_updating.search(line):
lang = re_qmlang.findall(line)
@@ -158,8 +158,8 @@ def main():
ignored = int(re_ignout.findall(line)[0])
else:
ignored = 0
- if lang[0] in langs:
- name = langs[lang[0]].strip()
+ if lang[0] in LANGS:
+ name = LANGS[lang[0]].strip()
else:
name = '(unknown)'
@@ -191,7 +191,6 @@ def main():
"%%ENDCOLOR%% %s |" %
(name, fancylang, translations, finished, unfinished,
ignored, tsdate, color, percent, bar))
- i += 1
if pretty:
print(delim)