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, ' ')
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, ' ')
def add_association(args): rowcount = item_store.db().associate(args.parent_name, args.child_name) output('associated %i item' % rowcount)
def delete(args): rowcount = item_store.db().delete_item(args.name) output('delted %i item' % rowcount)
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)
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)
def export(args): output('exporting database') dump_file = args.dump_file result = item_store.db().dump_db(dump_file) output(result)
def init(args): output('initializing database') result = item_store.initialize_db(item_store.db()) output(result)