示例#1
0
    def convert(self,lang,metabook):
        """
        Private.
        This function executes the programs for the conversion.
        @lang Language of book
        @metabook Path to metabook-json-file
        """
        print "Rendering language "+lang
        tmp = self.tmp
        docbookfile = os.path.join(tmp,"%s.xml"%lang)
        chmDest = os.path.join(self.dest,lang+".chm")

        renderArgs = ("-L",lang,"-W","imagesrcresolver=%s"%self.imgPath,
            "--config=%s/wikiconf.txt"%(tmp),
            "-w","docbook","-o",docbookfile,"-m",metabook,"--title",self.title)
        MW.quietCall(MW.render,renderArgs,showErr=self.verbose)
        shutil.copy(docbookfile,self.dest)
        print "Parsing docbook"
        xsltreturn = self.ex("/usr/bin/xsltproc","--nonet","--novalid","-o",tmp+'/',self.style,docbookfile)
        if not xsltreturn: return False
        self.setStartpage(self.startpage)
        self.writeHhp()
        if self.createChm:
            print("Compiling chm...")
            self.hhc(tmp)
            shutil.copy(os.path.join(tmp,'htmlhelp.chm'),chmDest)
        return True
示例#2
0
    def convert(self, lang, metabook):
        """
        Private.
        This function executes the programs for the conversion.
        @lang Language of book
        @metabook Path to metabook-json-file
        """
        print "Rendering language " + lang
        tmp = self.tmp
        docbookfile = os.path.join(tmp, "%s.xml" % lang)
        chmDest = os.path.join(self.dest, lang + ".chm")

        renderArgs = ("-L", lang, "-W", "imagesrcresolver=%s" % self.imgPath,
                      "--config=%s/wikiconf.txt" % (tmp), "-w", "docbook",
                      "-o", docbookfile, "-m", metabook, "--title", self.title)
        MW.quietCall(MW.render, renderArgs, showErr=self.verbose)
        shutil.copy(docbookfile, self.dest)
        print "Parsing docbook"
        xsltreturn = self.ex("/usr/bin/xsltproc", "--nonet", "--novalid", "-o",
                             tmp + '/', self.style, docbookfile)
        if not xsltreturn: return False
        self.setStartpage(self.startpage)
        self.writeHhp()
        if self.createChm:
            print("Compiling chm...")
            self.hhc(tmp)
            shutil.copy(os.path.join(tmp, 'htmlhelp.chm'), chmDest)
        return True