本文整理汇总了Python中Tribler.Core.CacheDB.SqliteCacheDBHandler.TorrentDBHandler.category方法的典型用法代码示例。如果您正苦于以下问题:Python TorrentDBHandler.category方法的具体用法?Python TorrentDBHandler.category怎么用?Python TorrentDBHandler.category使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tribler.Core.CacheDB.SqliteCacheDBHandler.TorrentDBHandler
的用法示例。
在下文中一共展示了TorrentDBHandler.category方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reimport_torrents
# 需要导入模块: from Tribler.Core.CacheDB.SqliteCacheDBHandler import TorrentDBHandler [as 别名]
# 或者: from Tribler.Core.CacheDB.SqliteCacheDBHandler.TorrentDBHandler import category [as 别名]
def reimport_torrents(self):
"""Import all torrent files in the collected torrent dir, all the files already in the database will be ignored.
"""
self.status_update_func("Opening TorrentDBHandler...")
# TODO(emilon): That's a freakishly ugly hack.
torrent_db_handler = TorrentDBHandler(self.session)
torrent_db_handler.category = Category()
# TODO(emilon): It would be nice to drop the corrupted torrent data from the store as a bonus.
self.status_update_func("Registering recovered torrents...")
try:
for infoshash_str, torrent_data in self.torrent_store.iteritems():
self.status_update_func("> %s" % infoshash_str)
torrentdef = TorrentDef.load_from_memory(torrent_data)
if torrentdef.is_finalized():
infohash = torrentdef.get_infohash()
if not torrent_db_handler.hasTorrent(infohash):
self.status_update_func(u"Registering recovered torrent: %s" % hexlify(infohash))
torrent_db_handler._addTorrentToDB(torrentdef, extra_info={"filename": infoshash_str})
finally:
torrent_db_handler.close()
self.db.commit_now()
return self.torrent_store.flush()