当前位置: 首页>>代码示例>>Python>>正文


Python DataSource.license_sources_for方法代码示例

本文整理汇总了Python中core.model.DataSource.license_sources_for方法的典型用法代码示例。如果您正苦于以下问题:Python DataSource.license_sources_for方法的具体用法?Python DataSource.license_sources_for怎么用?Python DataSource.license_sources_for使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.model.DataSource的用法示例。


在下文中一共展示了DataSource.license_sources_for方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: lookup_equivalent_isbns

# 需要导入模块: from core.model import DataSource [as 别名]
# 或者: from core.model.DataSource import license_sources_for [as 别名]
    def lookup_equivalent_isbns(self, identifier):
        """Finds NoveList data for all ISBNs equivalent to an identifier.

        :return: Metadata object or None
        """
        lookup_metadata = []
        license_sources = DataSource.license_sources_for(self._db, identifier)
        # Look up strong ISBN equivalents.
        for license_source in license_sources:
            lookup_metadata += [self.lookup(eq.output)
                for eq in identifier.equivalencies
                if (eq.data_source==license_source and eq.strength==1
                    and eq.output.type==Identifier.ISBN)]

        if not lookup_metadata:
            self.log.error(
                "Identifiers without an ISBN equivalent can't \
                be looked up with NoveList: %r", identifier
            )
            return None

        # Remove None values.
        lookup_metadata = [metadata for metadata in lookup_metadata if metadata]
        if not lookup_metadata:
            return None

        best_metadata = self.choose_best_metadata(lookup_metadata, identifier)
        if not best_metadata:
            metadata, confidence = best_metadata
            if round(confidence, 2) < 0.5:
                self.log.warn(self.NO_ISBN_EQUIVALENCY, identifier)
                return None
        return metadata
开发者ID:dguo,项目名称:circulation,代码行数:35,代码来源:novelist.py

示例2: lookup_equivalent_isbns

# 需要导入模块: from core.model import DataSource [as 别名]
# 或者: from core.model.DataSource import license_sources_for [as 别名]
    def lookup_equivalent_isbns(self, identifier):
        """Finds NoveList data for all ISBNs equivalent to an identifier.

        :return: Metadata object or None
        """
        lookup_metadata = []
        license_sources = DataSource.license_sources_for(self._db, identifier)

        # Find strong ISBN equivalents.
        isbns = list()
        for license_source in license_sources:
            isbns += [eq.output for eq in identifier.equivalencies if (
                eq.data_source==license_source and
                eq.strength==1 and
                eq.output.type==Identifier.ISBN
            )]

        if not isbns:
            self.log.warn(
                ("Identifiers without an ISBN equivalent can't"
                "be looked up with NoveList: %r"), identifier
            )
            return None

        # Look up metadata for all equivalent ISBNs.
        lookup_metadata = list()
        for isbn in isbns:
            metadata = self.lookup(isbn)
            if metadata:
                lookup_metadata.append(metadata)

        if not lookup_metadata:
            self.log.warn(
                ("No NoveList metadata found for Identifiers without an ISBN"
                "equivalent can't be looked up with NoveList: %r"), identifier
            )
            return None

        best_metadata, confidence = self.choose_best_metadata(
            lookup_metadata, identifier
        )
        if best_metadata:
            if round(confidence, 2) < 0.5:
                self.log.warn(self.NO_ISBN_EQUIVALENCY, identifier)
                return None
            return metadata
开发者ID:NYPL-Simplified,项目名称:circulation,代码行数:48,代码来源:novelist.py


注:本文中的core.model.DataSource.license_sources_for方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。