Esempio n. 1
0
def list_items(args):
    item_dict = item_store.db().select_all()
    if not args.tree:
        for x in item_dict.values():
            output(x)
    else:
        pairs_list = item_store.db().all_associations()
        build_tree(item_dict, pairs_list)
        for root in item_dict.values():
            if root.parents is None:
                root.traverse_children(show_item, '  ')
Esempio n. 2
0
def search(args):
    query = args.query
    output(query)
    item_dict, pairs_list = item_store.db().search(query)
    if False:
        for x in item_dict.values():
            output(x)
    else:
        build_tree(item_dict, pairs_list)
        for root in item_dict.values():
            if root.parents is None:
                root.traverse_children(show_item, '  ')
Esempio n. 3
0
def add_association(args):
    rowcount = item_store.db().associate(args.parent_name, args.child_name)
    output('associated %i item' % rowcount)
Esempio n. 4
0
def delete(args):
    rowcount = item_store.db().delete_item(args.name)
    output('delted %i item' % rowcount)
Esempio n. 5
0
def rename(args):
    old_name = args.old
    new_name = args.new
    rowcount = item_store.db().rename_item(old_name, new_name)
    output('renamed %i item' % rowcount)
Esempio n. 6
0
def create(args):
    item = Item(-1, args.type.upper(), args.name)
    rowid = item_store.db().create_item(item)
    output('created item with id: %i' % rowid)
Esempio n. 7
0
def export(args):
    output('exporting database')
    dump_file = args.dump_file
    result = item_store.db().dump_db(dump_file)
    output(result)
Esempio n. 8
0
def init(args):
    output('initializing database')
    result = item_store.initialize_db(item_store.db())
    output(result)