diff options
author | Parménides GV <parmegv@sdf.org> | 2015-06-04 19:20:15 +0200 |
---|---|---|
committer | Parménides GV <parmegv@sdf.org> | 2015-06-04 19:20:15 +0200 |
commit | 27594eeae6f40a402bc3110f06d57975168e74e3 (patch) | |
tree | cdabf6571e6f4ff07205fd6921d8095539a1fcdc /app/misc/genFAQ.py | |
parent | 8dc4f58d96892fbfd83094fb85b1d17656035290 (diff) |
ics-openvpn as a submodule! beautiful
ics-openvpn is now officially on GitHub, and they track openssl and
openvpn as submodules, so it's easier to update everything. Just a git
submodule update --recursive.
I've also set up soft links to native modules from ics-openvpn in app,
so that we don't copy files in Gradle (which was causing problems with
the submodules .git* files, not being copied). That makes the repo
cleaner.
Diffstat (limited to 'app/misc/genFAQ.py')
-rwxr-xr-x | app/misc/genFAQ.py | 135 |
1 files changed, 0 insertions, 135 deletions
diff --git a/app/misc/genFAQ.py b/app/misc/genFAQ.py deleted file mode 100755 index 9a0c9af5..00000000 --- a/app/misc/genFAQ.py +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env python -# Quick and dirty script to generate googlecode wiki pages - -import codecs -import xml.dom.minidom as dom -import os.path -import re - -faqpath = "/Users/arne/oss/ics-openvpn.wiki" - -header=""" -<wiki:comment> -This page is autogenerated. Do not edit -</wiki:comment> - -= Frequently aksed questions = -""" - -def getString(strid,lang): - ostr="" - if strid in strres[lang]: - ostr=strres[lang][strid] - else: - ostr=strres["default"][strid] - - ostr = ostr.replace("<","<") - ostr = ostr.replace(">",">") - ostr = ostr.replace("\\\"","\"") - ostr = ostr.replace("\\'","'") - ostr = ostr.replace("\\n","<p>") - return ostr - -def genPage(javafile, lang): - #{R.string.faq_howto_title, R.string.faq_howto}, - out ="" - out+= header - for l in javafile: - m = re.search("\{.*R.string.([a-z_]+),.*R.string.([a-z_]+)\}", l) - if m: - (title, body) = m.groups() - - out += "== %s ==\n" % getString(title,lang) - out += "%s\n" % getString(body,lang) - if body == "faq_system_dialogs_title": - out += "%s\n" % getString("faq_system_dialog_xposed",lang) - return out - -def genPageXML(faqdom,lang): - out ="" - - #out+="#summary %s\n" % getString("faq_summary",lang) - out+= header - - for xmld in faqdom.firstChild.childNodes: - for xmle in xmld.childNodes: - if xmle.nodeName == "TextView": - style = xmle.getAttribute("style") - - textstyle = None - if style == "@style/faqhead": - textstyle = "== %s ==\n" - elif style == "@style/faqitem": - textstyle = "%s\n" - - atext = xmle.getAttribute("android:text") - aid = xmle.getAttribute("android:id") - if atext: - atextid = atext.replace("@string/","") - else: - atextid = aid.replace("@+id/","") - - out += textstyle % getString(atextid,lang) - - return out - - -strres={} - -def loadstrres(filename,lang): - xmlstr = dom.parse(filename) - strres[lang]={} - for xmld in xmlstr.childNodes: - for xmle in xmld.childNodes: - if xmle.nodeName == "string": - strname= xmle.getAttribute("name") - strdata = xmle.firstChild.data - strres[lang][strname]=strdata - - -def main(): - - loadstrres("src/main/res/values/strings.xml","default") - - #faqdom = dom.parse("src/main/res/layout/faq.xml") - faqdom = open("src/main/java/de/blinkt/openvpn/fragments/FaqFragment.java").readlines() - faq= genPage(faqdom,"default") - - open(faqpath + "/FAQ.wiki","w").write(faq) - - for directory in os.listdir("src/main/res"): - if directory.startswith("values-") and directory.find("-sw")==-1 and not directory.startswith("values-v"): - lang = directory.split("-",1)[1] - print lang - loadstrres("src/main/res/values-%s/strings.xml" % lang,lang) - - langdir= "%s/%s" %(faqpath,lang) - if lang=="zh-rCN": - langdir= "%s/%s" %(faqpath,"zh-Hans") - elif lang=="zh-rTW": - langdir= "%s/%s" %(faqpath,"zh-Hant") - - - if not os.path.exists(langdir): - os.mkdir(langdir) - - faq= genPage(faqdom,lang) - open("%s/FAQ.wiki" % langdir,"w").write(faq.encode("utf-8")) - - checkFormatString(lang) - -def checkFormatString(lang): - for strid in strres["default"]: - ostr = getString(strid,"default") - tstr = getString(strid,lang) - - - for f in ["%s", "%d", "%f"] + ["%%%d$s" % d for d in range(0,10)] + ["%%%d$d" % d for d in range(0,10)]: - ino = ostr.find(f)==-1 - int = tstr.find(f)==-1 - - if ino != int: - print "Mismatch StringID(%s): " % lang,strid,"Original String:",ostr,"Translated String:",tstr - -if __name__=="__main__": - main() |