Did I find the right examples for you? yes no

All Samples(26)  |  Call(12)  |  Derive(0)  |  Import(14)

        def main(argv=None):
    from argparse import ArgumentParser
    from os.path import isfile
    from sys import stdin, stdout
    from yaml import load as yload

    try:
        from yaml import CLoader as YLoader
    except ImportError:
        from yaml import Loader as YLoader

    engines = { 'mako' : render_mako, 'jinja2' : render_jinja2 }
    
    parser = ArgumentParser(description="Render a file using templates.")
    parser.add_argument('-i', '--inputfile', help='input file')
    parser.add_argument('-e', '--engine', help='templating engine')
    parser.add_argument('-d', '--template_dirs',
                        help=': delimited template search path')
    parser.add_argument('-t', '--template', 
                        help='template to apply to input file')
    parser.add_argument('-b', '--block', help='template block to override')
    parser.add_argument('-m', '--metafile', action='append',
                        help='metadata file in yaml format')
    parser.add_argument('-v', '--var', action='append', default=[],
                        help='name=value pairs to be added to metadata')
    parser.add_argument('-o', '--outputfile', default='-', help='output file')
    parser.add_argument('-ienc', '--input_encoding', help='input encoding')
    parser.add_argument('-oenc', '--output_encoding', help='output encoding')

    args = parser.parse_args()

    meta = dict()

    # defaults...
    meta['inputfile'] = None
    meta['engine'] = 'mako'
    meta['template'] = None
    meta['block'] = None
    meta['template_dirs'] = ['.']
    meta['input_encoding'] = 'utf-8'
    meta['output_encoding'] = 'utf-8'
    meta['output_format'] = 'html5'
    meta['outputfile'] = '-'

    metafiles = []
    
    if isfile(config_file_name):
        metafiles.append(config_file_name)

    if args.metafile:
        metafiles += args.metafile

    if metafiles:
        for metafile in args.metafile:
            if isfile(metafile):
                meta.update(yload(open(metafile, 'r'), Loader=YLoader))
            else:
                raise SystemExit("error: can't find metafile %s" % metafile)

    if args.var:
        for pair in args.var:
            name, value = pair.split('=')
            meta[name] = value

    if args.inputfile:
        meta['inputfile'] = args.inputfile

    if args.engine:
        meta['engine'] = args.engine
    
    if args.template:
        meta['template'] = args.template
 
    if args.block:
        meta['block'] = args.block
    
    if args.template_dirs:
        meta['template_dirs'] = args.template_dirs.split(':')
    
    if args.input_encoding:
        meta['input_encoding'] = args.input_encoding
 
    if args.output_encoding:
        meta['output_encoding'] = args.output_encoding

    if args.outputfile:
        meta['outputfile'] = args.outputfile
    
    fp = None
    if meta['inputfile']:
        if meta['inputfile'] == '-':
            fp = stdin
        elif isfile(meta['inputfile']):
            fp = open(meta['inputfile'], 'r')
        else:
            raise SystemExit("error: can't find %s" % args.inputfile)

    data = ""
    if fp:
        data = fp.read()

    if meta['outputfile'] == '-':
        out = stdout
    else:
        out = open(args.outputfile, 'w')

    out.write(engines[meta['engine']](data, meta))
        


src/o/p/optutils-.02.6/optutils/__init__.py   optutils(Download)
#For licensing see the LICENSE file in the top level directory.
 
from util import main, custom_log_main
from lib import log, output, error_codes, add_code
 

src/o/p/OpenMDAO-Framework-HEAD/openmdao.gui/src/openmdao/gui/test/functional/test_project.py   OpenMDAO-Framework(Download)
from openmdao.main.releaseinfo import __version__
 
from util import main, setup_server, teardown_server, generate, \
                 begin, random_project, edit_project, import_project, \
                 get_browser_download_location_path, broken_chrome
 
if __name__ == '__main__':
    main()
 

src/o/p/OpenMDAO-Framework-HEAD/openmdao.gui/src/openmdao/gui/test/functional/test_workspace.py   OpenMDAO-Framework(Download)
from selenium.common.exceptions import StaleElementReferenceException, \
                                       WebDriverException
from util import main, setup_server, teardown_server, generate, \
                 startup, closeout, broken_chrome
 
 
if __name__ == '__main__':
    main()
 

src/o/p/OpenMDAO-Framework-HEAD/openmdao.gui/src/openmdao/gui/test/functional/test_codeeditor.py   OpenMDAO-Framework(Download)
from nose.tools import assert_not_equal as neq
 
from util import main, setup_server, teardown_server, generate, \
                 startup, closeout, broken_chrome
from pageobjects.util import NotifierPage
 
if __name__ == '__main__':
    main()
 

src/o/p/OpenMDAO-Framework-HEAD/openmdao.gui/src/openmdao/gui/test/functional/test_workflow.py   OpenMDAO-Framework(Download)
from nose.tools import with_setup
 
from util import main, setup_server, teardown_server, generate, \
                 startup, closeout
 
 
if __name__ == '__main__':
    main()
 

src/o/p/OpenMDAO-Framework-HEAD/openmdao.gui/src/openmdao/gui/test/functional/test_valueeditors.py   OpenMDAO-Framework(Download)
from pageobjects.basepageobject import TMO
 
from util import main, setup_server, teardown_server, generate, \
                 startup, closeout
 
 
if __name__ == '__main__':
    main()
 

src/o/p/OpenMDAO-Framework-HEAD/openmdao.gui/src/openmdao/gui/test/functional/test_tutorials.py   OpenMDAO-Framework(Download)
from nose.tools import with_setup
 
from util import main, setup_server, teardown_server, generate, \
                 startup, closeout
 
 
if __name__ == '__main__':
    main()
 

src/o/p/OpenMDAO-Framework-HEAD/openmdao.gui/src/openmdao/gui/test/functional/test_slots.py   OpenMDAO-Framework(Download)
from nose.tools import with_setup
 
from util import main, setup_server, teardown_server, generate, \
                 startup, closeout
 
 
if __name__ == '__main__':
    main()
 

src/o/p/OpenMDAO-Framework-HEAD/openmdao.gui/src/openmdao/gui/test/functional/test_passthrough_editor.py   OpenMDAO-Framework(Download)
from nose.tools import with_setup
 
from util import main, setup_server, teardown_server, generate, \
                 startup, closeout
 
 
if __name__ == '__main__':
    main()
 

src/o/p/OpenMDAO-Framework-HEAD/openmdao.gui/src/openmdao/gui/test/functional/test_io_variable_grids.py   OpenMDAO-Framework(Download)
 
from pageobjects.component import ComponentPage
from util import main, setup_server, teardown_server, generate, \
                 startup, closeout
 
 
if __name__ == '__main__':
    main()
 

  1 | 2  Next