本文整理汇总了Python中MaKaC.common.indexes.IndexesHolder.getById方法的典型用法代码示例。如果您正苦于以下问题:Python IndexesHolder.getById方法的具体用法?Python IndexesHolder.getById怎么用?Python IndexesHolder.getById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaKaC.common.indexes.IndexesHolder
的用法示例。
在下文中一共展示了IndexesHolder.getById方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fixIndexesEncoding
# 需要导入模块: from MaKaC.common.indexes import IndexesHolder [as 别名]
# 或者: from MaKaC.common.indexes.IndexesHolder import getById [as 别名]
def fixIndexesEncoding(dbi, withRBDB, prevVersion):
"""
Fix indexes encoding. They may be in unicode and they has to be encoded in utf-8
"""
INDEXES = ["name", "surName", "organisation"]
ih = IndexesHolder()
for idx_name in INDEXES:
idx = ih.getById(idx_name)
words = idx._words
for key in words.iterkeys():
newKey = fix_broken_string(key)
values = words[key]
del words[key]
words[newKey] = values
idx.setIndex(words)
dbi.commit()
示例2: fix_indexes
# 需要导入模块: from MaKaC.common.indexes import IndexesHolder [as 别名]
# 或者: from MaKaC.common.indexes.IndexesHolder import getById [as 别名]
def fix_indexes():
dbi = DBMgr.getInstance()
dbi.startRequest()
ih = IndexesHolder()
for idx_name in INDEXES:
idx = ih.getById(idx_name)
words = idx._words
for key in words.iterkeys():
newKey = fix_broken_string(key)
values = words[key]
del words[key]
words[newKey] = values
idx.setIndex(words)
dbi.commit()
dbi.endRequest()