本文整理汇总了Python中collection.Collection.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Collection.get_by_id方法的具体用法?Python Collection.get_by_id怎么用?Python Collection.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collection.Collection
的用法示例。
在下文中一共展示了Collection.get_by_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display_collection
# 需要导入模块: from collection import Collection [as 别名]
# 或者: from collection.Collection import get_by_id [as 别名]
def display_collection(self, id):
collection = Collection.get_by_id(self.db, id);
if collection == None:
raise Exception("No collection with id {}!".format(id))
Collection.print_table_header()
collection.print_for_table()
items = Item.get_by_collection(self.db, collection.id)
print("ITEMS")
Item.print_table_header()
for item in items:
item.print_for_table()
示例2: process_staging
# 需要导入模块: from collection import Collection [as 别名]
# 或者: from collection.Collection import get_by_id [as 别名]
def process_staging(functions):
#Get all files in staging directory
files = [ f for f in listdir(functions.stage) if isfile(join(functions.stage,f)) ]
for file in files:
collection_id = -1
collection_path = ""
#List collections for user
functions.list_collections()
print("N. New Collection")
print("File: {}".format(file))
val = input("Select collection to use (id): ")
#Get or create selected collection
if val == "N":
coll = create_collection(functions.library, functions.db)
collection_id = coll.id
collection_path = coll.path
else:
coll = Collection.get_by_id(functions.db, int(val))
collection_id = coll.id
collection_path = coll.path
#Assign name and move file
val = input("Enter a name for {} (if blank filename will be used): ".format(file))
item_name = val
if item_name == "":
item_name = file
item = Item(None, collection_id, item_name, file)
rename(join(functions.stage, file), join(functions.library, collection_path, file))
#Persist
item.insert(functions.db)
print("Staging processed!")
示例3: delete_collection
# 需要导入模块: from collection import Collection [as 别名]
# 或者: from collection.Collection import get_by_id [as 别名]
def delete_collection(self, id):
collection = Collection.get_by_id(self.db, id);
collection.delete();