当前位置: 首页>>代码示例>>Python>>正文


Python Collection.get_by_id方法代码示例

本文整理汇总了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()
开发者ID:ByzantineFailure,项目名称:Spike,代码行数:13,代码来源:functions.py

示例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!")
开发者ID:ByzantineFailure,项目名称:Spike,代码行数:38,代码来源:functions.py

示例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();
开发者ID:ByzantineFailure,项目名称:Spike,代码行数:5,代码来源:functions.py


注:本文中的collection.Collection.get_by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。