Пример #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 )
Пример #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)
Пример #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 )
Пример #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)