本文整理汇总了Python中mkt.webapps.indexers.WebappIndexer.extract_document方法的典型用法代码示例。如果您正苦于以下问题:Python WebappIndexer.extract_document方法的具体用法?Python WebappIndexer.extract_document怎么用?Python WebappIndexer.extract_document使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mkt.webapps.indexers.WebappIndexer
的用法示例。
在下文中一共展示了WebappIndexer.extract_document方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from mkt.webapps.indexers import WebappIndexer [as 别名]
# 或者: from mkt.webapps.indexers.WebappIndexer import extract_document [as 别名]
def setUp(self):
self.feed = self.feed_factory()
self.data_es = [
feed_item.get_indexer().extract_document(None, obj=feed_item)
for feed_item in self.feed]
# Denormalize feed elements into the serializer context.
self.app_map = {}
self.feed_element_map = defaultdict(dict)
for i, feed_item in enumerate(self.data_es):
feed_element = getattr(self.feed[i], feed_item['item_type'])
self.feed_element_map[feed_item['item_type']][feed_element.id] = (
feed_element.get_indexer().extract_document(None,
obj=feed_element))
# Denormalize apps into serializer context.
if hasattr(feed_element, 'apps'):
for app in feed_element.apps():
self.app_map[app.id] = WebappIndexer.extract_document(
None, obj=app)
else:
self.app_map[feed_element.app_id] = (
WebappIndexer.extract_document(feed_element.app_id))
self.context = {
'app_map': self.app_map,
'feed_element_map': self.feed_element_map,
'request': mkt.site.tests.req_factory_factory('')
}
示例2: setUp
# 需要导入模块: from mkt.webapps.indexers import WebappIndexer [as 别名]
# 或者: from mkt.webapps.indexers.WebappIndexer import extract_document [as 别名]
def setUp(self):
self.apps = [amo.tests.app_factory() for i in range(3)]
self.app_ids = [app.id for app in self.apps]
self.brand = self.feed_brand_factory(app_ids=self.app_ids)
self.data_es = self.brand.get_indexer().extract_document(
None, obj=self.brand)
self.app_map = dict((app.id, WebappIndexer.extract_document(app.id))
for app in self.apps)
示例3: test_background_image
# 需要导入模块: from mkt.webapps.indexers import WebappIndexer [as 别名]
# 或者: from mkt.webapps.indexers.WebappIndexer import extract_document [as 别名]
def test_background_image(self):
self.feedapp.update(type=feed.FEEDAPP_IMAGE, image_hash='LOL')
self.data_es = self.feedapp.get_indexer().extract_document(
None, obj=self.feedapp)
self.app_map = {
self.feedapp.app_id: WebappIndexer.extract_document(
self.feedapp.app_id)
}
data = serializers.FeedAppESSerializer(
self.data_es, context=self.context).data
assert data['background_image'].endswith('image.png?LOL')
示例4: index_webapps
# 需要导入模块: from mkt.webapps.indexers import WebappIndexer [as 别名]
# 或者: from mkt.webapps.indexers.WebappIndexer import extract_document [as 别名]
def index_webapps(ids, **kw):
"""TODO: use search/indexers.py:index."""
task_log.info('Indexing apps %s-%s. [%s]' % (ids[0], ids[-1], len(ids)))
index = kw.pop('index', WebappIndexer.get_index())
# Note: If reindexing is currently occurring, `get_indices` will return
# more than one index.
indices = Reindexing.get_indices(index)
es = WebappIndexer.get_es(urls=settings.ES_URLS)
qs = Webapp.indexing_transformer(Webapp.with_deleted.no_cache().filter(
id__in=ids))
for obj in qs:
doc = WebappIndexer.extract_document(obj.id, obj)
for idx in indices:
WebappIndexer.index(doc, id_=obj.id, es=es, index=idx)
示例5: _get_doc
# 需要导入模块: from mkt.webapps.indexers import WebappIndexer [as 别名]
# 或者: from mkt.webapps.indexers.WebappIndexer import extract_document [as 别名]
def _get_doc(self):
qs = Webapp.objects.no_cache().filter(id__in=[self.app.pk])
obj = qs[0]
return obj, WebappIndexer.extract_document(obj.pk, obj)