authorities.py 文件源码

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

项目:almar 作者: scriptotek 项目源码 文件源码
def authorize_concept(self, concept):
        if '2' not in concept.sf:
            raise ValueError('No vocabulary code (2) given!')
        if concept.sf['2'] in self.vocabularies:
            vocab = self.vocabularies[concept.sf['2']]
        else:
            log.info(Fore.RED + '?' + Style.RESET_ALL + ' Could not authorize: %s', concept)
            return

        response = vocab.authorize_term(concept.term, concept.tag)

        if response.get('id') is not None:
            identifier = response.get('id')
            if concept.sf.get('0'):
                if concept.sf.get('0') == ANY_VALUE:
                    pass  # ignore ANY_VALUE
                elif identifier != concept.sf['0']:
                    identifier = pick_one('The $$0 value does not match the authority record id. ' +
                                          'Please select which to use',
                                          [concept.sf['0'], identifier])
            concept.sf['0'] = identifier
            log.info(Fore.GREEN + '?' + Style.RESET_ALL + ' Authorized: %s', concept)
        else:
            log.info(Fore.RED + '?' + Style.RESET_ALL + ' Could not authorize: %s', concept)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号