Beispiel #1
0
def main():
    from pluggdapps import loadpackages
    import pluggdapps.commands

    loadpackages()  # This is important, otherwise plugins in other packages 
                    # will not be detected.

    # Create command line parser.
    # Get a list of sub-commands supported in command line.
    # Take only the command-line parameters uptil a subcommand.
    mainparser = mainoptions()
    mainargs = pluggdapps.commands.mainargs(ICommand, 'pagd.*', sys.argv[1:])
    args = mainparser.parse_args( mainargs )

    pa = Pluggdapps.boot( args.config )
    subcommands = pa.qpr( pa, ICommand, 'pagd.*' )

    # setup sub-command arguments
    subparsers = mainparser.add_subparsers( help="Sub-commands" )
    [ subcmd.subparser( mainparser, subparsers ) for subcmd in subcommands ]

    # Do a full parsing of command line arguments.
    args = mainparser.parse_args()

    args.sitepath = abspath( args.sitepath )

    # Corresponding handler is expected to be registered during subparser()
    # call above.
    args.handler( args )
Beispiel #2
0
def main():
    from pluggdapps import loadpackages
    import pluggdapps.commands

    loadpackages()  # This is important, otherwise plugins in other packages
    # will not be detected.

    # Create command line parser.
    # Get a list of sub-commands supported in command line.
    # Take only the command-line parameters uptil a subcommand.
    mainparser = mainoptions()
    mainargs = pluggdapps.commands.mainargs(ICommand, 'pluggdapps.*',
                                            sys.argv[1:])
    args = mainparser.parse_args(mainargs)

    if args.webapps:
        pa = Webapps.boot(args.config)
        subcommands = pa.qpr(pa, None, ICommand, 'pluggdapps.*')
    else:
        pa = Pluggdapps.boot(args.config)
        subcommands = pa.qpr(pa, ICommand, 'pluggdapps.*')

    # setup sub-command arguments
    subparsers = mainparser.add_subparsers(help="Sub-commands")
    [subcmd.subparser(mainparser, subparsers) for subcmd in subcommands]

    # Do a full parsing of command line arguments.
    args = mainparser.parse_args()

    # Corresponding handler is expected to be registered during subparser()
    # call above.
    args.handler(args)
Beispiel #3
0
def main() :
    from pluggdapps import loadpackages

    loadpackages()  # This is important, otherwise plugins in other packages 
                    # will not be detected.

    argparser = mainoptions()
    options = argparser.parse_args()
    pa = Pluggdapps.boot( None )
    
    # Initialize plugins
    setts = {
        'lex_debug'  : int( options.debug ),
        'yacc_debug' : int( options.debug ),
        'debug'      : True,
    }

    compiler = pa.qp( pa, ISettings, 'tayra.ttlcompiler', settings=setts )
    if options.version :
        print( tayra.__version__ )

    elif options.test :
        from tayra.test.teststd import test_stdttl
        print( "Executing TTL tests ..." )
        setts['beautify_html'] = False
        compiler = pa.qp( pa, ISettings, 'tayra.ttlcompiler', settings=setts )
        test_stdttl( compiler, options )

    elif options.ttllex and options.ttlfile : 
        print( "Lexing file %r ..." % options.ttlfile )
        lexical( pa, options )

    elif options.dump and options.ttlfile :
        print( "Parsing and dumping file %r ..." % options.ttlfile )
        ast = yaccer( pa, options, debuglevel=int(options.debug) )
        dumptext = ast.dump( context=Context() )
        text = open( options.ttlfile, encoding='utf-8-sig' ).read()
        if dumptext != text :
            open( 'dump', 'w' ).write( dumptext )
            open( 'text', 'w' ).write( text )
            assert False
        print( "Dump of AST matches the original text :)")

    elif options.show and options.ttlfile :
        print( "Parsing and describing file %r ..." % options.ttlfile )
        ast = yaccer( pa, options, debuglevel=int(options.debug) )
        ast.show()

    elif options.ttlfile and isfile( options.ttlfile ) :
        print( "Translating file %r ..." % options.ttlfile )
        tayra.translatefile( options.ttlfile, compiler, options )
Beispiel #4
0
def main():
    from pluggdapps import loadpackages

    loadpackages()  # This is important, otherwise plugins in other packages
    # will not be detected.

    argparser = mainoptions()
    options = argparser.parse_args()
    pa = Pluggdapps.boot(None)

    # Initialize plugins
    setts = {
        'lex_debug': int(options.debug),
        'yacc_debug': int(options.debug),
        'debug': True,
    }

    compiler = pa.qp(pa, ISettings, 'tayra.ttlcompiler', settings=setts)
    if options.version:
        print(tayra.__version__)

    elif options.test:
        from tayra.test.teststd import test_stdttl
        print("Executing TTL tests ...")
        setts['beautify_html'] = False
        compiler = pa.qp(pa, ISettings, 'tayra.ttlcompiler', settings=setts)
        test_stdttl(compiler, options)

    elif options.ttllex and options.ttlfile:
        print("Lexing file %r ..." % options.ttlfile)
        lexical(pa, options)

    elif options.dump and options.ttlfile:
        print("Parsing and dumping file %r ..." % options.ttlfile)
        ast = yaccer(pa, options, debuglevel=int(options.debug))
        dumptext = ast.dump(context=Context())
        text = open(options.ttlfile, encoding='utf-8-sig').read()
        if dumptext != text:
            open('dump', 'w').write(dumptext)
            open('text', 'w').write(text)
            assert False
        print("Dump of AST matches the original text :)")

    elif options.show and options.ttlfile:
        print("Parsing and describing file %r ..." % options.ttlfile)
        ast = yaccer(pa, options, debuglevel=int(options.debug))
        ast.show()

    elif options.ttlfile and isfile(options.ttlfile):
        print("Translating file %r ..." % options.ttlfile)
        tayra.translatefile(options.ttlfile, compiler, options)
Beispiel #5
0
def tayratemplate( dirname, verbose=False ):
    from pluggdapps.platform import Pluggdapps
    from pluggdapps.plugin   import ISettings
    pa = Pluggdapps.boot( None )
    settings = {
        'directories' : [dirname],
        'debug' : True,
        'beautify_html' : False,
    }
    options = O()
    compiler = pa.query_plugin(
                    pa, ISettings, 'tayra.TTLCompiler', settings=settings )
    options.context = dict( 
            title='Just a test', user='******',
            list_items=['Number %d' % num for num in range(1, 15)]
    )
    def render() :
        tayra.translatefile( './tayra/template.ttl', compiler, options )

    if verbose:
        print( render() )
    return render
Beispiel #6
0
    sys.path[:0] = new_sys_path

    # Avoid ``[Errno 13] Permission denied: '/var/www/.python-eggs'`` messages
    os.environ['PYTHON_EGG_CACHE'] = join( pa_dir(), 'egg-cache' )

    # IMPORTANT : pluggdapps package can be imported only at this stage, after
    # setting up the virtual environment.
    import pluggdapps
    from   pluggdapps.erlcodec import *
    from   pluggdapps.const import *
    from   pluggdapps.platform import Pluggdapps

    args.configini = args.configini or DEFAULT_INI

    if args.use_descrs :
        descrs = tuple( map( int, args.use_descrs.split(',') ))
    elif args.nouse_stdio :
        descrs = (3,4)
    else : 
        descrs = (0,1)

    erlport = Pluggdapps.boot( args.configini,
                               # Initializers for Pluggdapps() class
                               erlang=True,
                               # Initializers for Port() class.
                               descrs=descrs,
                               packet=int(args.packet), 
                               compressed=args.compressed )
    run( erlport )

Beispiel #7
0
    options, args = _option_parse()


    if options.version :
        print tss.__version__

    elif args and isfile(args[0]) :
        ttlloc = args.pop(0)
        tss.tss_cmdline( ttlloc, _options=options )
    elif int(options.debug) :
        TSSParser( tssconfig={}, debug=int(options.debug) )

def main()
    argparser = mainoptions()
    options = argparser.parse_args()
    pa = Pluggdapps.boot( None )
    
    # Initialize plugins
    setts = {
        'lex_debug'  : int( options.debug ),
        'yacc_debug' : int( options.debug ),
        'debug'      : True,
    }

    compiler = pa.query_plugin( pa, ISettings, 'tsscompiler', settings=setts )
    if options.version :
        print( tss.__version__ )

    elif options.test :
        pass