summaryrefslogtreecommitdiff
path: root/genFAQ.py
diff options
context:
space:
mode:
authorSean Leonard <meanderingcode@aetherislands.net>2013-07-26 15:30:24 -0600
committerSean Leonard <meanderingcode@aetherislands.net>2013-07-26 15:30:24 -0600
commitf49967fb3f24bf0a22d09b5823bd174a45e758f7 (patch)
tree7fefe9ec3aeff998c5dd99861428717a2c5f3a41 /genFAQ.py
parent8dbb4517b07c42c3b37b0764d63973b5b1ed5ee6 (diff)
parentb69c9a87f60e649221c8f83d58bbd57b35a64aca (diff)
Merge branch 'release-0.2.0'0.2.0
Diffstat (limited to 'genFAQ.py')
-rwxr-xr-xgenFAQ.py96
1 files changed, 0 insertions, 96 deletions
diff --git a/genFAQ.py b/genFAQ.py
deleted file mode 100755
index 1815f7a2..00000000
--- a/genFAQ.py
+++ /dev/null
@@ -1,96 +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
-
-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):
- if strid in strres[lang]:
- return strres[lang][strid]
- else:
- return strres["default"][strid]
-
-def genPage(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("res/values/strings.xml","default")
-
- faqdom = dom.parse("res/layout/faq.xml")
- faq= genPage(faqdom,"default")
-
- open(faqpath + "/FAQ.wiki","w").write(faq)
-
- for directory in os.listdir("res"):
- if directory.startswith("values-"):
- lang = directory.split("-",1)[1]
- loadstrres("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)
-
- print lang
- faq= genPage(faqdom,lang)
- open("%s/FAQ.wiki" % langdir,"w").write(faq.encode("utf-8"))
-
-
-if __name__=="__main__":
- main()