示例#1
0
文件: cli.py 项目: GunioRobot/been
def add(app, kind, *args):
    """add <kind> (parameters): Registers a source of the specified <kind>."""
    source_cls = source_map.get(kind)
    if source_cls:
        app.add(source_cls.configure(*args))
    else:
        print "Invalid source kind '{kind}' specified. Must be one of:".format(kind=kind)
        for kind in source_map:
            print "  " + kind
        sys.exit(1)
示例#2
0
文件: cli.py 项目: Cornellio/been
def add(app, kind=None, *args):
    """add <kind> (parameters): Registers a source of the specified <kind>."""
    source_cls = source_map.get(kind)
    if not source_cls:
        if kind is not None:
            print "Invalid source kind '{kind}' specified.".format(kind=kind)
        else:
            print add.__doc__
        print "Available source kinds:"
        for kind in source_map:
            print "  " + kind
        sys.exit(1)

    source = source_cls.configure(*args)

    if source.source_id in app.sources:
        print "A source with id '{id}' already exists.".format(id=source.source_id)
        return

    app.add(source)
示例#3
0
文件: cli.py 项目: chromakode/been
def add(app, kind=None, *args):
    """add <kind> (parameters): Registers a source of the specified <kind>."""
    source_cls = source_map.get(kind)
    if not source_cls:
        if kind is not None:
            print "Invalid source kind '{kind}' specified.".format(kind=kind)
        else:
            print add.__doc__
        print "Available source kinds:"
        for kind in source_map:
            print "  " + kind
        sys.exit(1)

    source = source_cls.configure(*args)

    if source.source_id in app.sources:
        print "A source with id '{id}' already exists.".format(
            id=source.source_id)
        return

    app.add(source)