| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

FillTmpl::__init__ Namespace Reference


Functions

def load_cls
def dj_fill
def main

Function Documentation

def FillTmpl::__init__::load_cls (   spec  ) 

Definition at line 12 of file __init__.py.

00012                   :
00013     spec = spec.split('.')
00014     modl = __import__( '.'.join(spec[:-1]) , fromlist=[spec[-1]] )
00015     cls = getattr( modl , spec[-1] )
00016     return cls
00017 
00018 
def dj_fill( src, _ ):

def FillTmpl::__init__::dj_fill (   src,
  _ 
)

Definition at line 19 of file __init__.py.

00019                      :
00020     opts, args = _
00021     try:
00022         parser_cls = load_cls(opts.parser)
00023     except:
00024         raise Exception("failed to load parser class with spec %s" % opts.parser )
00025     parser = parser_cls()
00026     ctx = parser( src )  
00027 
00028     extras = getattr( ctx , 'extras' , {} )
00029 
00030     if opts.debug:
00031         print "FillTmpl debug.. "
00032         print locals()
00033 
00034     import django
00035     import django.template.loader      ##  http://code.djangoproject.com/ticket/7377
00036     from django.template import Context, Template
00037  
00038     import os
00039     dbg = os.environ.has_key('VERBOSE')   
00040     tmpl = os.path.expandvars( opts.template )
00041     tdir = os.path.dirname( tmpl )
00042     django.conf.settings.configure(DEBUG=dbg, TEMPLATE_DEBUG=dbg, TEMPLATE_STRING_IF_INVALID="filltmpl-missing-noodles", TEMPLATE_DIRS=(tdir,) )
00043     t = Template( file(tmpl).read() )
00044     template_object_name = extras.pop('template_object_name', 't' )
00045     c = Context( { template_object_name:ctx } )
00046     c.update( extras )
00047     return t.render( c )
00048 
def main():

def FillTmpl::__init__::main (  ) 

Definition at line 49 of file __init__.py.

00049           :
00050     import sys
00051     from optparse import OptionParser
00052     opr = OptionParser() 
00053     opr.add_option("-p", "--parser",   help="python dotted spec of callable parser class" )
00054     opr.add_option("-t", "--template", help="path to template file" )
00055     opr.add_option("-d", "--debug"   , action="store_true", help="provide debug output" )
00056     opr.set_defaults( debug=False, ctxobj=False, parser="DybDbiPre.Parser", template="$DYBDBIROOT/templates/T.h" )  ## just strings no dependency on DybDbi
00057     print dj_fill( sys.stdin, opr.parse_args() ) 
00058 
00059 
if __name__=='__main__':

| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:13:24 2011 for FillTmpl by doxygen 1.4.7