Пример #1
0
 def writeall(self):
     ''' Very different writeall:
         there is no tree of nodes; there is no grammar.structure/recorddefs; kid opens file by itself.
     '''
     try:
         from genshi.template import TemplateLoader
     except:
         txt = botslib.txtexc()
         raise ImportError(_(u'Dependency failure: editype "template" requires python library "genshi". Error:\n%s'%txt))
     #for template-grammar: only syntax is used. Section 'syntax' has to have 'template'
     self.outmessagegrammarread(self.ta_info['editype'],self.ta_info['messagetype'])
     templatefile = botslib.abspath(u'templateshtml',self.ta_info['template'])
     try:
         botsglobal.logger.debug(u'Start writing to file "%s".',self.ta_info['filename'])
         loader = TemplateLoader(auto_reload=False)
         tmpl = loader.load(templatefile)
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(_(u'While templating "$editype.$messagetype", error:\n$txt'),editype=self.ta_info['editype'],messagetype=self.ta_info['messagetype'],txt=txt)
     try:
         filehandler = botslib.opendata(self.ta_info['filename'],'wb')
         stream = tmpl.generate(data=self.data)
         stream.render(method='xhtml',encoding=self.ta_info['charset'],out=filehandler)
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(_(u'While templating "$editype.$messagetype", error:\n$txt'),editype=self.ta_info['editype'],messagetype=self.ta_info['messagetype'],txt=txt)
     botsglobal.logger.debug(_(u'End writing to file "%s".'),self.ta_info['filename'])
Пример #2
0
 def run(self):
     ''' class for template enveloping; delevers a valid html-file.
         Uses a kid-template for the enveloping/merging.
         use kid to write; no envelope grammar is used
         #20120101 depreciated. use class templatehtml
     '''
     try:
         import kid
     except:
         raise ImportError(_(u'Dependency failure: editype "template" requires python library "kid".'))
     self._openoutenvelope()
     self.ta_info.update(self.out.ta_info)
     botslib.tryrunscript(self.userscript,self.scriptname,'ta_infocontent',ta_info=self.ta_info)
     if not self.ta_info['envelope-template']:
         raise botslib.OutMessageError(_(u'While enveloping in "%(editype)s.%(messagetype)s": syntax option "envelope-template" not filled; is required.'),
                                         self.ta_info)
     templatefile = botslib.abspath('templates',self.ta_info['envelope-template'])
     ta_list = self.filelist2absolutepaths()
     try:
         botsglobal.logger.debug(u'Start writing envelope to file "%(filename)s".',self.ta_info)
         ediprint = kid.Template(file=templatefile, data=ta_list) #init template; pass list with filenames
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(_(u'While enveloping in "%(editype)s.%(messagetype)s", error:\n%(txt)s'),
                                         {'editype':self.ta_info['editype'],'messagetype':self.ta_info['messagetype'],'txt':txt})
     try:
         filehandler = botslib.opendata(self.ta_info['filename'],'wb')
         ediprint.write(filehandler,
                         encoding=self.ta_info['charset'],
                         output=self.ta_info['output'])
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(_(u'While enveloping in "%(editype)s.%(messagetype)s", error:\n%(txt)s'),
                                         {'editype':self.ta_info['editype'],'messagetype':self.ta_info['messagetype'],'txt':txt})
Пример #3
0
 def writeall(self):
     ''' Very different writeall:
         there is no tree of nodes; there is no grammar.structure/recorddefs; kid opens file by itself.
     '''
     try:
         import kid
     except:
         txt = botslib.txtexc()
         raise ImportError(_(u'Dependency failure: editype "template" requires python library "kid". Error:\n%s'%txt))
     #for template-grammar: only syntax is used. Section 'syntax' has to have 'template'
     self.outmessagegrammarread(self.ta_info['editype'],self.ta_info['messagetype'])
     templatefile = botslib.abspath(u'templates',self.ta_info['template'])
     try:
         botsglobal.logger.debug(u'Start writing to file "%s".',self.ta_info['filename'])
         ediprint = kid.Template(file=templatefile, data=self.data)
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(_(u'While templating "$editype.$messagetype", error:\n$txt'),editype=self.ta_info['editype'],messagetype=self.ta_info['messagetype'],txt=txt)
     try:
         filehandler = botslib.opendata(self.ta_info['filename'],'wb')
         ediprint.write(filehandler,
                         encoding=self.ta_info['charset'],
                         output=self.ta_info['output'],    #output is specific parameter for class; init from grammar.syntax
                         fragment=self.ta_info['merge'])
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(_(u'While templating "$editype.$messagetype", error:\n$txt'),editype=self.ta_info['editype'],messagetype=self.ta_info['messagetype'],txt=txt)
     botsglobal.logger.debug(_(u'End writing to file "%s".'),self.ta_info['filename'])
Пример #4
0
 def run(self):
     ''' class for (test) orderprint; delevers a valid html-file.
         Uses a kid-template for the enveloping/merging.
         use kid to write; no envelope grammar is used
     '''
     import kid
     defmessage = grammar.grammarread(self.ta_info['editype'],self.ta_info['messagetype'])   #needed beause we do not know envelope; read syntax for editype/messagetype
     self.ta_info.update(defmessage.syntax)
     botslib.tryrunscript(self.userscript,self.scriptname,'ta_infocontent',ta_info=self.ta_info)
     if not self.ta_info['envelope-template']:
         raise botslib.OutMessageError(_(u'While enveloping in "$editype.$messagetype": syntax option "envelope-template" not filled; is required.'),editype=self.ta_info['editype'],messagetype=self.ta_info['messagetype'])
     templatefile = botslib.abspath('templates',self.ta_info['envelope-template'])
     ta_list = self.filelist2absolutepaths()
     try:
         botsglobal.logger.debug(u'Start writing envelope to file "%s".',self.ta_info['filename'])
         ediprint = kid.Template(file=templatefile, data=ta_list) #init template; pass list with filenames
     except:
         txt=botslib.txtexc()
         raise botslib.OutMessageError(_(u'While enveloping in "$editype.$messagetype": $txt'),editype=self.ta_info['editype'],messagetype=self.ta_info['messagetype'],txt=txt)
     try:
         f = botslib.opendata(self.ta_info['filename'],'wb')
         ediprint.write(f,
                         encoding=self.ta_info['charset'],
                         output=self.ta_info['output'])
     except:
         txt=botslib.txtexc()
         raise botslib.OutMessageError(_(u'While enveloping error in "$editype.$messagetype"; probably in html file(s) to be merged: $txt'),editype=self.ta_info['editype'],messagetype=self.ta_info['messagetype'],txt=txt)
Пример #5
0
 def run(self):
     try:
         from genshi.template import TemplateLoader
     except:
         raise ImportError(u'Dependency failure: editype "templatehtml" requires python library "genshi".')
     self._openoutenvelope()
     self.ta_info.update(self.out.ta_info)
     botslib.tryrunscript(self.userscript,self.scriptname,'ta_infocontent',ta_info=self.ta_info)
     if not self.ta_info['envelope-template']:
         raise botslib.OutMessageError(_(u'While enveloping in "%(editype)s.%(messagetype)s": syntax option "envelope-template" not filled; is required.'),
                                         self.ta_info)
     templatefile = botslib.abspath(self.__class__.__name__,self.ta_info['envelope-template'])
     ta_list = self.filelist2absolutepaths()
     try:
         botsglobal.logger.debug(u'Start writing envelope to file "%(filename)s".',self.ta_info)
         loader = TemplateLoader(auto_reload=False)
         tmpl = loader.load(templatefile)
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(_(u'While enveloping in "%(editype)s.%(messagetype)s", error:\n%(txt)s'),
                                     {'editype':self.ta_info['editype'],'messagetype':self.ta_info['messagetype'],'txt':txt})
     try:
         filehandler = botslib.opendata(self.ta_info['filename'],'wb')
         stream = tmpl.generate(data=ta_list)
         stream.render(method='xhtml',encoding=self.ta_info['charset'],out=filehandler)
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(_(u'While enveloping in "%(editype)s.%(messagetype)s", error:\n%(txt)s'),
                                     {'editype':self.ta_info['editype'],'messagetype':self.ta_info['messagetype'],'txt':txt})
Пример #6
0
 def run(self):
     ''' class for (test) orderprint; delevers a valid html-file.
         Uses a kid-template for the enveloping/merging.
         use kid to write; no envelope grammar is used
     '''
     try:
         from genshi.template import TemplateLoader
     except:
         txt=botslib.txtexc()
         raise ImportError(_(u'Dependency failure: editype "template" requires python library "genshi". Error:\n%s'%txt))
     defmessage = grammar.grammarread(self.ta_info['editype'],self.ta_info['messagetype'])   #needed because we do not know envelope; read syntax for editype/messagetype
     self.ta_info.update(defmessage.syntax)
     botslib.tryrunscript(self.userscript,self.scriptname,'ta_infocontent',ta_info=self.ta_info)
     if not self.ta_info['envelope-template']:
         raise botslib.OutMessageError(_(u'While enveloping in "$editype.$messagetype": syntax option "envelope-template" not filled; is required.'),editype=self.ta_info['editype'],messagetype=self.ta_info['messagetype'])
     templatefile = botslib.abspath('templateshtml',self.ta_info['envelope-template'])
     ta_list = self.filelist2absolutepaths()
     try:
         botsglobal.logger.debug(u'Start writing envelope to file "%s".',self.ta_info['filename'])
         loader = TemplateLoader(auto_reload=False)
         tmpl = loader.load(templatefile)
     except:
         txt=botslib.txtexc()
         raise botslib.OutMessageError(_(u'While enveloping in "$editype.$messagetype", error:\n$txt'),editype=self.ta_info['editype'],messagetype=self.ta_info['messagetype'],txt=txt)
     try:
         f = botslib.opendata(self.ta_info['filename'],'wb')
         stream = tmpl.generate(data=ta_list)
         stream.render(method='xhtml',encoding=self.ta_info['charset'],out=f)
     except:
         txt=botslib.txtexc()
         raise botslib.OutMessageError(_(u'While enveloping in "$editype.$messagetype", error:\n$txt'),editype=self.ta_info['editype'],messagetype=self.ta_info['messagetype'],txt=txt)
Пример #7
0
 def writeall(self):
     ''' Very different writeall:
         there is no tree of nodes; there is no grammar.structure/recorddefs; kid opens file by itself.
     '''
     try:
         from genshi.template import TemplateLoader
     except:
         txt=botslib.txtexc()
         raise ImportError(_(u'Dependency failure: editype "template" requires python library "genshi". Error:\n%s'%txt))
     #for template-grammar: only syntax is used. Section 'syntax' has to have 'template'
     self.outmessagegrammarread(self.ta_info['editype'],self.ta_info['messagetype'])
     templatefile = botslib.abspath(u'templateshtml',self.ta_info['template'])
     try:
         botsglobal.logger.debug(u'Start writing to file "%s".',self.ta_info['filename'])
         loader = TemplateLoader(auto_reload=False)
         tmpl = loader.load(templatefile)
     except:
         txt=botslib.txtexc()
         raise botslib.OutMessageError(_(u'While templating "$editype.$messagetype", error:\n$txt'),editype=self.ta_info['editype'],messagetype=self.ta_info['messagetype'],txt=txt)
     try:
         f = botslib.opendata(self.ta_info['filename'],'wb')
         stream = tmpl.generate(data=self.data)
         stream.render(method='xhtml',encoding=self.ta_info['charset'],out=f)
     except:
         txt=botslib.txtexc()
         raise botslib.OutMessageError(_(u'While templating "$editype.$messagetype", error:\n$txt'),editype=self.ta_info['editype'],messagetype=self.ta_info['messagetype'],txt=txt)
     botsglobal.logger.debug(_(u'End writing to file "%s".'),self.ta_info['filename'])
Пример #8
0
 def writeall(self):
     ''' Very different writeall:
         there is no tree of nodes; there is no grammar.structure/recorddefs; kid opens file by itself.
     '''
     try:
         import kid
     except:
         txt=botslib.txtexc()
         raise ImportError(_(u'Dependency failure: editype "template" requires python library "kid". Error:\n%s'%txt))
     #for template-grammar: only syntax is used. Section 'syntax' has to have 'template'
     self.outmessagegrammarread(self.ta_info['editype'],self.ta_info['messagetype'])
     templatefile = botslib.abspath(u'templates',self.ta_info['template'])
     try:
         botsglobal.logger.debug(u'Start writing to file "%s".',self.ta_info['filename'])
         ediprint = kid.Template(file=templatefile, data=self.data)
     except:
         txt=botslib.txtexc()
         raise botslib.OutMessageError(_(u'While templating "$editype.$messagetype", error:\n$txt'),editype=self.ta_info['editype'],messagetype=self.ta_info['messagetype'],txt=txt)
     try:
         f = botslib.opendata(self.ta_info['filename'],'wb')
         ediprint.write(f,
         #~ ediprint.write(botslib.abspathdata(self.ta_info['filename']),
                         encoding=self.ta_info['charset'],
                         output=self.ta_info['output'],    #output is specific parameter for class; init from grammar.syntax
                         fragment=self.ta_info['merge'])
     except:
         txt=botslib.txtexc()
         raise botslib.OutMessageError(_(u'While templating "$editype.$messagetype", error:\n$txt'),editype=self.ta_info['editype'],messagetype=self.ta_info['messagetype'],txt=txt)
     botsglobal.logger.debug(_(u'End writing to file "%s".'),self.ta_info['filename'])
Пример #9
0
 def run(self):
     ''' class for (test) orderprint; delevers a valid html-file.
         Uses a kid-template for the enveloping/merging.
         use kid to write; no envelope grammar is used
     '''
     try:
         from genshi.template import TemplateLoader
     except:
         txt = botslib.txtexc()
         raise ImportError(
             _(u'Dependency failure: editype "template" requires python library "genshi". Error:\n%s'
               % txt))
     defmessage = grammar.grammarread(
         self.ta_info['editype'], self.ta_info['messagetype']
     )  #needed because we do not know envelope; read syntax for editype/messagetype
     self.ta_info.update(defmessage.syntax)
     botslib.tryrunscript(self.userscript,
                          self.scriptname,
                          'ta_infocontent',
                          ta_info=self.ta_info)
     if not self.ta_info['envelope-template']:
         raise botslib.OutMessageError(_(
             u'While enveloping in "$editype.$messagetype": syntax option "envelope-template" not filled; is required.'
         ),
                                       editype=self.ta_info['editype'],
                                       messagetype=self.
                                       ta_info['messagetype'])
     templatefile = botslib.abspath('templateshtml',
                                    self.ta_info['envelope-template'])
     ta_list = self.filelist2absolutepaths()
     try:
         botsglobal.logger.debug(u'Start writing envelope to file "%s".',
                                 self.ta_info['filename'])
         loader = TemplateLoader(auto_reload=False)
         tmpl = loader.load(templatefile)
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(
             _(u'While enveloping in "$editype.$messagetype", error:\n$txt'
               ),
             editype=self.ta_info['editype'],
             messagetype=self.ta_info['messagetype'],
             txt=txt)
     try:
         filehandler = botslib.opendata(self.ta_info['filename'], 'wb')
         stream = tmpl.generate(data=ta_list)
         stream.render(method='xhtml',
                       encoding=self.ta_info['charset'],
                       out=filehandler)
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(
             _(u'While enveloping in "$editype.$messagetype", error:\n$txt'
               ),
             editype=self.ta_info['editype'],
             messagetype=self.ta_info['messagetype'],
             txt=txt)
Пример #10
0
 def run(self):
     ''' class for (test) orderprint; delevers a valid html-file.
         Uses a kid-template for the enveloping/merging.
         use kid to write; no envelope grammar is used
     '''
     try:
         import kid
     except:
         txt = botslib.txtexc()
         raise ImportError(
             _(u'Dependency failure: editype "template" requires python library "kid". Error:\n%s'
               % txt))
     defmessage = grammar.grammarread(
         self.ta_info['editype'], self.ta_info['messagetype']
     )  #needed because we do not know envelope; read syntax for editype/messagetype
     self.ta_info.update(defmessage.syntax)
     botslib.tryrunscript(self.userscript,
                          self.scriptname,
                          'ta_infocontent',
                          ta_info=self.ta_info)
     if not self.ta_info['envelope-template']:
         raise botslib.OutMessageError(_(
             u'While enveloping in "$editype.$messagetype": syntax option "envelope-template" not filled; is required.'
         ),
                                       editype=self.ta_info['editype'],
                                       messagetype=self.
                                       ta_info['messagetype'])
     templatefile = botslib.abspath('templates',
                                    self.ta_info['envelope-template'])
     ta_list = self.filelist2absolutepaths()
     try:
         botsglobal.logger.debug(u'Start writing envelope to file "%s".',
                                 self.ta_info['filename'])
         ediprint = kid.Template(
             file=templatefile,
             data=ta_list)  #init template; pass list with filenames
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(
             _(u'While enveloping in "$editype.$messagetype", error:\n$txt'
               ),
             editype=self.ta_info['editype'],
             messagetype=self.ta_info['messagetype'],
             txt=txt)
     try:
         filehandler = botslib.opendata(self.ta_info['filename'], 'wb')
         ediprint.write(filehandler,
                        encoding=self.ta_info['charset'],
                        output=self.ta_info['output'])
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(
             _(u'While enveloping in "$editype.$messagetype", error:\n$txt'
               ),
             editype=self.ta_info['editype'],
             messagetype=self.ta_info['messagetype'],
             txt=txt)
Пример #11
0
 def run(self):
     try:
         from genshi.template import TemplateLoader
     except:
         raise ImportError(
             u'Dependency failure: editype "templatehtml" requires python library "genshi".'
         )
     self._openoutenvelope()
     self.ta_info.update(self.out.ta_info)
     botslib.tryrunscript(self.userscript,
                          self.scriptname,
                          'ta_infocontent',
                          ta_info=self.ta_info)
     if not self.ta_info['envelope-template']:
         raise botslib.OutMessageError(
             _(u'While enveloping in "%(editype)s.%(messagetype)s": syntax option "envelope-template" not filled; is required.'
               ), self.ta_info)
     templatefile = botslib.abspath(self.__class__.__name__,
                                    self.ta_info['envelope-template'])
     ta_list = self.filelist2absolutepaths()
     try:
         botsglobal.logger.debug(
             u'Start writing envelope to file "%(filename)s".',
             self.ta_info)
         loader = TemplateLoader(auto_reload=False)
         tmpl = loader.load(templatefile)
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(
             _(u'While enveloping in "%(editype)s.%(messagetype)s", error:\n%(txt)s'
               ), {
                   'editype': self.ta_info['editype'],
                   'messagetype': self.ta_info['messagetype'],
                   'txt': txt
               })
     try:
         filehandler = botslib.opendata(self.ta_info['filename'], 'wb')
         stream = tmpl.generate(data=ta_list)
         stream.render(method='xhtml',
                       encoding=self.ta_info['charset'],
                       out=filehandler)
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(
             _(u'While enveloping in "%(editype)s.%(messagetype)s", error:\n%(txt)s'
               ), {
                   'editype': self.ta_info['editype'],
                   'messagetype': self.ta_info['messagetype'],
                   'txt': txt
               })
Пример #12
0
 def run(self):
     """ class for (test) orderprint; delevers a valid html-file.
         Uses a kid-template for the enveloping/merging.
         use kid to write; no envelope grammar is used
     """
     try:
         import kid
     except:
         txt = botslib.txtexc()
         raise ImportError(
             _(u'Dependency failure: editype "template" requires python library "kid". Error:\n%s' % txt)
         )
     defmessage = grammar.grammarread(
         self.ta_info["editype"], self.ta_info["messagetype"]
     )  # needed because we do not know envelope; read syntax for editype/messagetype
     self.ta_info.update(defmessage.syntax)
     botslib.tryrunscript(self.userscript, self.scriptname, "ta_infocontent", ta_info=self.ta_info)
     if not self.ta_info["envelope-template"]:
         raise botslib.OutMessageError(
             _(
                 u'While enveloping in "$editype.$messagetype": syntax option "envelope-template" not filled; is required.'
             ),
             editype=self.ta_info["editype"],
             messagetype=self.ta_info["messagetype"],
         )
     templatefile = botslib.abspath("templates", self.ta_info["envelope-template"])
     ta_list = self.filelist2absolutepaths()
     try:
         botsglobal.logger.debug(u'Start writing envelope to file "%s".', self.ta_info["filename"])
         ediprint = kid.Template(file=templatefile, data=ta_list)  # init template; pass list with filenames
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(
             _(u'While enveloping in "$editype.$messagetype", error:\n$txt'),
             editype=self.ta_info["editype"],
             messagetype=self.ta_info["messagetype"],
             txt=txt,
         )
     try:
         filehandler = botslib.opendata(self.ta_info["filename"], "wb")
         ediprint.write(filehandler, encoding=self.ta_info["charset"], output=self.ta_info["output"])
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(
             _(u'While enveloping in "$editype.$messagetype", error:\n$txt'),
             editype=self.ta_info["editype"],
             messagetype=self.ta_info["messagetype"],
             txt=txt,
         )
Пример #13
0
 def _write(self,node_instance):
     templatefile = botslib.abspath(self.__class__.__name__,self.ta_info['template'])
     try:
         botsglobal.logger.debug(u'Start writing to file "%(filename)s".',self.ta_info)
         loader = self.template.TemplateLoader(auto_reload=False)
         tmpl = loader.load(templatefile)
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(_(u'While templating "%(editype)s.%(messagetype)s", error:\n%(txt)s'),
                                         {'editype':self.ta_info['editype'],'messagetype':self.ta_info['messagetype'],'txt':txt})
     try:
         filehandler = botslib.opendata(self.ta_info['filename'],'wb')
         if self.ta_info['has_structure']:   #new way of working
             if self.ta_info['print_as_row']:
                 node_instance.collectlines(self.ta_info['print_as_row'])
             stream = tmpl.generate(node=node_instance)
         else:
             stream = tmpl.generate(data=self.data)
         stream.render(method='xhtml',encoding=self.ta_info['charset'],out=filehandler)
     except:
         txt = botslib.txtexc()
         raise botslib.OutMessageError(_(u'While templating "%(editype)s.%(messagetype)s", error:\n%(txt)s'),
                                         {'editype':self.ta_info['editype'],'messagetype':self.ta_info['messagetype'],'txt':txt})
     botsglobal.logger.debug(_(u'End writing to file "%(filename)s".'),self.ta_info)