__init__.py 文件源码

python
阅读 55 收藏 0 点赞 0 评论 0

项目:lagendacommun 作者: ecreall 项目源码 文件源码
def content_types_analyzer(node, source, validated):
    """Return for example
    {'content_types': {
      'artist': 8610, 'person': 3, 'cinema_review': 769, 'venue': 729,
       'cultural_event': 2487, 'organization': 1, 'review': 4187}
    }
    only includes content type != 0
    """
    if 'metadata_filter' in validated:
        validated['metadata_filter'].pop('content_types', None)

    objects = source(**validated)
    index = find_catalog('system')['content_type']
    intersection = index.family.IF.intersection
    object_ids = getattr(objects, 'ids', objects)
    if isinstance(object_ids, (list, types.GeneratorType)):
        object_ids = index.family.IF.Set(object_ids)

    result = [(content_type, len(intersection(object_ids, oids)))
              for content_type, oids in index._fwd_index.items()]
    result = dict([(k, v) for k, v in result if v != 0])
    return {'content_types': result}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号