Package sabx10 :: Package templating :: Module sabx :: Class SabxProcessor
[hide private]
[frames] | no frames]

Class SabxProcessor

source code

               object --+    
                        |    
generic.TemplateProcessor --+
                            |
                           SabxProcessor
Known Subclasses:

The SabxProcessor sub-classes the TemplateProcessor class. It provides an extendable framework for processing SABX 1.0 files with Jinja2 templates. It builds on the generic TemplateProcessor by adding an "infile" option to specify the SABX 1.0 file and by providing a routine for parsing the SABX 1.0 data.

Sample Code::

 from sabx10.templating import SabxProcessor
 SabxProcessor().process()

Sample Usage::

 $ sample.py -i sample.sabx -o sample.out sample.jinja2
Instance Methods [hide private]
 
__init__(self, template_file=None, man=None)
Adds the "infile" command-line option specifying the SABX 1.0 file to read from to the options specified in the base class.
source code
 
get_template_data(self)
Parse the specified SABX 1.0 file and save its object representation.
source code
 
process_template(self)
Process the SABX 1.0 data into the template.
source code

Inherited from generic.TemplateProcessor: process, process_options

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
file in_file
handle to file to read SABX 1.0 data from
dict sabx
dic holding all the data for the given SABX 1.0 file

Inherited from generic.TemplateProcessor: args, man, options, out_file, parser, template_data, template_file, template_path

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, template_file=None, man=None)
(Constructor)

source code 

Adds the "infile" command-line option specifying the SABX 1.0 file to read from to the options specified in the base class.

Parameters:
  • template_file (string) - (optional) path & file name of a template file
  • man (string) - (optional) extended program help information
Overrides: object.__init__

get_template_data(self)

source code 

Parse the specified SABX 1.0 file and save its object representation. Over-ride this in sub-classes to modify the SABX data before passing it to the template.

Overrides: generic.TemplateProcessor.get_template_data

process_template(self)

source code 

Process the SABX 1.0 data into the template. First, delete the input file if it is the same as the output file. This way you can read an SABX 1.0 file and write the template output to the same file name, effectively over-writing the file.

Overrides: generic.TemplateProcessor.process_template