def save(self): if not hasattr(self, 'latex_body'): self.to_latex() self.fulllist = self.header+self.latex_body ed = '\\end{document}' if ed not in self.fulllist and hasattr(self,'header'): self.fulllist.append(ed) pytexutils.writefile(self.pathout, self.fulllist)
def save_rst(self): if not hasattr(self, 'rst'): self.to_rst() fno, ext = os.path.splitext(self.index_name) self.rst_name = fno+'.rst' my_dir = self.get_main_dir() self.rst_path = os.path.join(my_dir, self.rst_name) pytexutils.writefile(self.rst_path, self.rst)
def EvtWLTtoTexmaxima(self, event): wltpath = self.wltchooser.GetPath() wlttrans = texmaxima.WLTTranslator(wltpath) wlttrans.Read() latexlist = wlttrans.Translate()#a pure Python list pno, ext = os.path.splitext(wltpath) texpath = pno+'.tex' pytexutils.writefile(texpath, latexlist) self.texmaximaoutput.SetPath(texpath)
def EvtRunButton(self, event): #get the path to the starting wlt file wltpath = self.filechooser.GetPath() #convert to wxm and save wltfile = wxmlit.wxmLitFile(wltpath) wxmfile = wltfile.ToWXM() #wxm to LaTeX in (this is not a legitimate tex file - it includes \maxima{...} and similar environments wxmpath = wxmfile.pathin fno,ext = os.path.splitext(wxmpath) texpath = fno+'.tex' print('wxmpath='+wxmpath) print('texpath='+texpath) wlttrans = texmaxima.WLTTranslator(wltpath) wlttrans.Read() latexlist = wlttrans.Translate()#a pure Python list pytexutils.writefile(texpath, latexlist) findlist = [] self.replacelist = replacelist.ReplaceList() self.replacelist.ReadFRFile() optdict = self.latexopts.GetSettings() if optdict['usefancyhdr'] and (self.fancyhdrpanel is not None): headerlines = self.fancyhdrpanel.GetLatexLines() print('\n'*3) print('fancyhdrpanel lines:') for line in headerlines: print line print('\n'*3) inpath = texpath pno, ext = os.path.splitext(inpath) outpath2 = pno+'_out.tex' self.texmaxima = texmaxima.TexMaximaFile(inpath) self.texmaxima.RunMaxima() self.texmaxima.SubstituteLatex(echo=0, replacelist=self.replacelist) self.texmaxima.AddHeader() if optdict['usefancyhdr'] and (self.fancyhdrpanel is not None): headerlines = self.fancyhdrpanel.GetLatexLines() print('\n'*3) print('fancyhdrpanel lines:') for line in headerlines: print line print('\n'*3) self.texmaxima.HeaderInsert(headerlines) self.texmaxima.SaveLatex(filename=outpath2) maxfindlist = self.texmaxima.FindReplacePats() findlist.extend(maxfindlist) self.replacelist.AppendFRFile(findlist) if optdict['runlatex']: outputpath3 = pytexutils.RunLatex(outpath2, sourcespecials=True, log=None, **optdict) self.OutputChooser.SetPath(outputpath3) else: self.OutputChooser.SetPath(outpath2)
def save(self, pathout=None): if pathout is None: pathout = self.rst_path pytexutils.writefile(pathout, self.rst_list) return pathout