diff options
author | Timo Richter <timo@iera.de> | 2011-08-17 09:51:29 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2011-08-26 14:07:36 +0200 |
commit | 818e5670a47b56963411e29f38a83a55e2eedd86 (patch) | |
tree | 89efa7ae182adab3c7a2d4bf2e559d051d3e5470 | |
parent | ba84d4ed501e1ae10683c2edf72ef2d3944e1333 (diff) |
Book title is now being read from input file
Less verbosity
Inclusion of images as a directory for the output of docbooks
5 files changed, 30 insertions, 9 deletions
diff --git a/helpcontent2/wiki-to-help/convert.py b/helpcontent2/wiki-to-help/convert.py index 0e6cf0b694..80187a68d1 100755 --- a/helpcontent2/wiki-to-help/convert.py +++ b/helpcontent2/wiki-to-help/convert.py @@ -61,7 +61,7 @@ class Converter(object): keepTmp = None # #style=os.path.join(scriptpath,'xsl/htmlhelp/htmlhelp.xsl') # final style=os.path.join(scriptpath,'htmlhelp.xsl') # final - title="LibreOffice" # final + title="Book" # final tmp=None includeFiles=[] @@ -87,6 +87,25 @@ class Converter(object): self.verbose = verbose self.ex = Executor(showErr=verbose,showOutput=True,showCmd=verbose) self.hhc = HHC(showErr=True,showOutput=verbose,showCmd=verbose) + self.title = self.getTitle(self.title) + + def getTitle(self,default=None): + """ + If given, return TEXT from <siteinfo><sitename>TEXT</sitename></siteinfo> + in xml file self.source. + Otherwise return @default + """ + import xml.dom.minidom + print "Loading title" + dom = xml.dom.minidom.parse(self.source) + try: + siteinfo = dom.getElementsByTagName("siteinfo")[0] + sitename = siteinfo.getElementsByTagName("sitename")[0] + name = sitename.childNodes[0].data + except IndexError: + return default + else: + return name def createDir(self,path): try: @@ -107,11 +126,12 @@ class Converter(object): return extension = os.path.splitext(self.imgPath)[1].lower() imgTmp = os.path.join(self.tmp,"images") - print "Moving images..." + print "Copying images..." if extension == ".zip": self.ex("unzip","-q","-o","-j","-d",imgTmp,self.imgPath) else: shutil.copytree(self.imgPath,imgTmp) + shutil.copytree(imgTmp, os.path.join(self.dest,imgDest) ) self.imgPath = os.path.join(imgDest,"IMAGENAME") # Save filenames for inclusion in chm for fname in os.listdir(imgTmp): @@ -135,6 +155,8 @@ class Converter(object): tmp = self.tmp self.createDir(self.dest) + print "Working directory: "+tmp + self.setupImgPath() shutil.copy(os.path.join(scriptpath,"nfo.json"),tmp) @@ -158,7 +180,7 @@ class Converter(object): """ print "Rendering language "+lang tmp = self.tmp - docbookfile = os.path.join(tmp,"docbook_%s.xml"%lang) + docbookfile = os.path.join(tmp,"%s.xml"%lang) chmDest = os.path.join(self.dest,lang+".chm") renderArgs = ("-L",lang,"-W","imagesrcresolver=%s"%self.imgPath, diff --git a/helpcontent2/wiki-to-help/mwlib_mods/custom_nfo.py b/helpcontent2/wiki-to-help/mwlib_mods/custom_nfo.py index e1df7845de..9d60fe6c8e 100644 --- a/helpcontent2/wiki-to-help/mwlib_mods/custom_nfo.py +++ b/helpcontent2/wiki-to-help/mwlib_mods/custom_nfo.py @@ -11,7 +11,6 @@ class WikiDB(mwlib.cdbwiki.WikiDB): except(RuntimeError): print("Warning: "+"could not get siteinfo for language %r" % (lang,)) print("Please set up a custom siteinfo and nfo.") - print "Mod: WikiDB" self.nfo = self.get_data("nfo") or self.nfo self.siteinfo = self.get_data("siteinfo") or self.siteinfo diff --git a/helpcontent2/wiki-to-help/mwlib_mods/docbook_internLinks.py b/helpcontent2/wiki-to-help/mwlib_mods/docbook_internLinks.py index 558e2a5a85..3f09bb363b 100644 --- a/helpcontent2/wiki-to-help/mwlib_mods/docbook_internLinks.py +++ b/helpcontent2/wiki-to-help/mwlib_mods/docbook_internLinks.py @@ -33,7 +33,9 @@ def setupGrammar(): ## Set up docbookwriter import mwlib.docbookwriter -import lxml.etree +#import lxml.etree +Element = mwlib.docbookwriter.Element +SubElement = mwlib.docbookwriter.SubElement class MyDocBookWriter(mwlib.docbookwriter.DocBookWriter): def getTargetId(self,title): """ Transform "The first article" to "The_first_article" """ @@ -51,7 +53,6 @@ class MyDocBookWriter(mwlib.docbookwriter.DocBookWriter): return e def dbwriteArticleLink(self, obj): - Element = mwlib.docbookwriter.Element a = Element("link") if obj.target: a.set("linkend", obj.target) diff --git a/helpcontent2/wiki-to-help/mwlib_mods/docbookwriter_options.py b/helpcontent2/wiki-to-help/mwlib_mods/docbookwriter_options.py index 7b11324766..e5b4350f96 100644 --- a/helpcontent2/wiki-to-help/mwlib_mods/docbookwriter_options.py +++ b/helpcontent2/wiki-to-help/mwlib_mods/docbookwriter_options.py @@ -37,7 +37,6 @@ def setupWriter(): import mwlib.docbookwriter class MyDocBookWriter(mwlib.docbookwriter.DocBookWriter): def dbwriteImageLink(self, obj): - print "Mod:dbwriteImageLink" if obj.target: name = obj.target obj.target = name[name.find(":") + 1:] diff --git a/helpcontent2/wiki-to-help/mwlib_mods/no_sections.py b/helpcontent2/wiki-to-help/mwlib_mods/no_sections.py index 6869fed411..d01b7b9514 100644 --- a/helpcontent2/wiki-to-help/mwlib_mods/no_sections.py +++ b/helpcontent2/wiki-to-help/mwlib_mods/no_sections.py @@ -5,10 +5,10 @@ Writes <article>...</article> instead of <article><section>...</section></articl import mwlib.docbookwriter #import lxml.etree -#Element = mwlib.docbookwriter.Element +Element = mwlib.docbookwriter.Element +SubElement = mwlib.docbookwriter.SubElement class MyDocBookWriter(mwlib.docbookwriter.DocBookWriter): def dbwriteArticle(self, a): - from mwlib.docbookwriter import * """ this generates the root element if not available """ |