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)
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)
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)