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 /helpcontent2/wiki-to-help/convert.py | |
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
Diffstat (limited to 'helpcontent2/wiki-to-help/convert.py')
-rwxr-xr-x | helpcontent2/wiki-to-help/convert.py | 28 |
1 files changed, 25 insertions, 3 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, |