本文整理汇总了Python中MaKaC.plugins.base.PluginsHolder.isUsable方法的典型用法代码示例。如果您正苦于以下问题:Python PluginsHolder.isUsable方法的具体用法?Python PluginsHolder.isUsable怎么用?Python PluginsHolder.isUsable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaKaC.plugins.base.PluginsHolder
的用法示例。
在下文中一共展示了PluginsHolder.isUsable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: chatroomIndexMigration
# 需要导入模块: from MaKaC.plugins.base import PluginsHolder [as 别名]
# 或者: from MaKaC.plugins.base.PluginsHolder import isUsable [as 别名]
def chatroomIndexMigration(dbi, withRBDB, prevVersion):
"""
Migrating Chat Room index to new structure
"""
# The structure of the indexes is such that for each one self._data
# is a BTree and each node is referenced by the IndexBy___ designation,
# where ___ is the ID in question. Each node is then a TreeSet of
# ChatRoom or XMPPChatRoom objects originally orderded by ID, we need
# this to be ordered by title for effective searching / querying.
# The __cmp__ method has been altered to accommodate this new format,
# take each subnode, iterate through saving the current objects, clear the
# index and reinsert them - they will now be in the correct order.
from MaKaC.plugins.InstantMessaging.indexes import IndexByUser, IndexByConf, IndexByCRName, IndexByID
im_plugin = PluginsHolder().getPluginType('InstantMessaging')
if not im_plugin.isUsable():
print console.colored(' IM plugin not usable - jumping task', 'yellow')
return
try:
for idx in [IndexByUser(), IndexByConf(), IndexByCRName()]:
tmp_idx = defaultdict(list)
print console.colored(" * Index: " + str(idx), 'blue')
for key, node in idx._data.iteritems():
for leaf in node:
tmp_idx[key].append(leaf)
# reset index
idx._data.clear()
for accum, rooms in tmp_idx.iteritems():
for room in rooms:
# Specific handling as IndexByUser & IndexByConf have different
# arguements for tree insertion.
if isinstance(idx, IndexByUser) or isinstance(idx, IndexByConf):
idx.index(str(accum), room)
else:
idx.index(room)
print console.colored("\tAll indexes have now been re-indexed and committed to the DB.", 'green')
except:
dbi.abort()
print console.colored("Process failed, ended abruptly, changes not committed.", 'red')
raise