es.py 文件源码

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

项目:mygene.info 作者: biothings 项目源码 文件源码
def _get_options(self, options, kwargs):
        # this species parameter is added to the query, thus will
        # change facet counts.
        kwargs['species'] = self._cleaned_species(kwargs.get('species', None))
        include_tax_tree = kwargs.pop('include_tax_tree', False)
        if include_tax_tree:
            headers = {'content-type': 'application/x-www-form-urlencoded',
                       'user-agent': "Python-requests_mygene.info/%s (gzip)"
                       % requests.__version__}
            # TODO: URL as config param
            res = requests.post('http://t.biothings.io/v1/taxon?ids=' +
                                ','.join(['{}'.format(sid) for sid in
                                          kwargs['species']]) +
                                '&expand_species=true', headers=headers)
            if res.status_code == requests.codes.ok:
                kwargs['species'] = res.json()

        # this parameter is to add species filter without
        # changing facet counts.
        kwargs['species_facet_filter'] = self._cleaned_species(
                kwargs.get('species_facet_filter', None), default_to_none=True)
        options.kwargs = kwargs
        return options
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号