Exemplo n.º 1
0
def prerun(ctx, cmdline):
    global diskdata

    argv = cmdline.split(' ')
    ctx.opts = util.get_opts(ctx.usage, argv=argv)

    if not diskdata:
        diskdata = yaml_load(open(ctx.opts.flags.file))

    return [ diskdata ]
Exemplo n.º 2
0
def prerun(ctx, cmdline):

    """
    Process context before subcommand invocation.
    This function is part of the ``serve()`` signature
    to allow a customized prerun.
    """

    argv = cmdline.split(" ")
    ctx.opts = util.get_opts(ctx.usage, argv=argv)
Exemplo n.º 3
0
    def test_data_check_path( self, testnr, pathexpr, expected ):

        """
        data-check-path should evalue path expression and return data
        """

        infile = StringIO('{"foo":[{"bar":null}]}')
        ctx = confparse.Values(dict(
            opts=util.get_opts(jsotk.__doc__, argv=['path', '', pathexpr])
        ))

        self.assertEquals( ctx.opts.args.pathexpr, pathexpr )

        is_new = jsotk_lib.data_check_path( ctx, infile )

        self.assert_( is_new == expected, testnr )
Exemplo n.º 4
0
        continue
    handlers[k[2:].replace('_', '-')] = h


def main(func=None, opts=None):
    """Shows basic usage of the Google Books API.
    """
    credentials = get_credentials(APPLICATION_NAME, opts.flags.secret,
            CRED_FILE, SCOPES)
    http = credentials.authorize(httplib2.Http())
    service = discovery.build('books', 'v1', http=http)

    return handlers[func](service, opts)



if __name__ == '__main__':
    import sys
    opts = util.get_opts(__doc__)
    if not opts.cmds:
        opts.cmds = ['list']
    if not opts.flags.secret:
        if 'GOOGLE_SCRIPT_JSON_SECRET_FILE' in os.environ:
            opts.flags.secret = os.environ['GOOGLE_SCRIPT_JSON_SECRET_FILE']
        else:
            opts.flags.secret = CLIENT_SECRET_FILE
    sys.exit( main( opts.cmds[0], opts ) )



Exemplo n.º 5
0
commands = util.get_cmd_handlers_2(globals(), 'cmd_')



### Util functions to run above functions from cmdline

def main(opts):

    """
    Execute command.
    """

    settings = opts.flags
    opts.default = ['info']
    return util.run_commands(commands, settings, opts)

def get_version():
    return 'redmine-meta.mpe/%s' % __version__

argument_handlers = {
}

if __name__ == '__main__':

    import sys
    opts = util.get_opts(__usage__, meta=argument_handlers, version=get_version())
    opts.flags.dbref = opts.flags.dbref
    sys.exit(main(opts))