コード例 #1
0
def main(bf):
    args = docopt(__doc__)

    item = get_item(args['<item>'], bf)

    if args['<destination>']:
        destination = get_item(args['<destination>'], bf)
    else:
        # item will be moved to to the top of its containing dataset
        destination = None

    if destination is None or isinstance(destination, Collection):
        try:
            bf.move(destination, item)
        except Exception, e:
            logger.error(e)
            exit("Failed to move {} into {}.".format(item, destination))
コード例 #2
0
ファイル: bf_get.py プロジェクト: rlmv/blackfynn-python
def main(bf):
    args = docopt(__doc__)

    if args['<item>']:
        item = get_item(args['<item>'], bf)
    else:
        item = require_working_dataset(bf)

    display(item, args['--tree'])
コード例 #3
0
ファイル: bf_delete.py プロジェクト: rlmv/blackfynn-python
def main(bf):
    args = docopt(__doc__)

    try:
        item = get_item(args['<item>'], bf)

        if not (isinstance(item, Collection) or isinstance(item, DataPackage)):
            raise Exception("only data packages and collections may be deleted.")

        bf.delete(item)
    except Exception, e:
        exit("  failed to delete {}: {}".format(args['<item>'], e))
コード例 #4
0
def main(bf):
    args = docopt(__doc__)

    collection = Collection(args['<name>'])

    if args['<destination>']:
        parent = get_item(args['<destination>'], bf)
        resp = parent.add(collection)
    else:
        dataset = require_working_dataset(bf)
        resp = dataset.add(collection)

    print(collection)
コード例 #5
0
ファイル: bf_props.py プロジェクト: rlmv/blackfynn-python
def main(bf):
    args = docopt(__doc__)

    item = get_item(args['<item>'], bf)
    key = args['<key>']
    cat = args['--category']

    if args['get']:
        if key:
            prop = get_prop(item, key, cat)
            if prop is None: return
            print "{cat} / {key}: {value}".format(cat=prop.category,
                                                  key=prop.key,
                                                  value=prop.value)
            return
        for prop in item.properties:
            print " * {cat} / {key}: {value}".format(cat=prop.category,
                                                     key=prop.key,
                                                     value=prop.value)
    elif args['set']:
        val = args['<value>']
        dtype = args['--type']
        if dtype not in Property._data_types:
            print "Error: Data type must be one of {}".format(
                Property._data_types)
            return
        item.insert_property(key, val, category=cat, data_type=dtype)
        print "SET {cat} / {key} = {value} ({type})".format(cat=cat,
                                                            key=key,
                                                            value=val,
                                                            type=dtype)
    elif args['rm']:
        prop = get_prop(item, key, cat)
        if prop is None: return
        item.remove_property(prop.key, category=prop.category)
        print "REMOVED {cat} / {key}".format(cat=cat, key=key)
コード例 #6
0
ファイル: bf_rename.py プロジェクト: rlmv/blackfynn-python
def main(bf):
    args = docopt(__doc__)

    item = get_item(args['<item>'], bf)
    item.name = args['<new_name>']
    item.update()
コード例 #7
0
ファイル: bf_where.py プロジェクト: rlmv/blackfynn-python
def main(bf):
    args = docopt(__doc__)

    item = get_item(args['<item>'], bf)
    print_path_tree(bf, [item])