Ejemplo n.º 1
0
    def __init__(self,
                 collection,
                 mirror=None,
                 http_get=None,
                 viaf=None,
                 provide_coverage_immediately=False,
                 force=False,
                 provider_kwargs=None,
                 **kwargs):
        """Constructor.

        :param collection: Handle all Identifiers from this Collection
        that were previously registered with this CoverageProvider.

        :param mirror: A MirrorUploader to use if coverage requires
        uploading any cover images to external storage.

        :param http_get: A drop-in replacement for
        Representation.simple_http_get, to be used if any information
        (such as a book cover) needs to be obtained from the public
        Internet.

        :param viaf_client: A VIAFClient to use if coverage requires
        gathering information about authors from VIAF.

        :param force: Force CoverageProviders to cover identifiers
        even if they believe they have already done the work.

        :param provide_coverage_immediately: If this is True, then
        resolving an identifier means registering it with all of its
        other CoverageProviders *and then attempting to provide
        coverage*.  Registration is considered a success even if the
        other CoverageProviders fail, but the attempt must be made
        immediately.

        If this is False (the default), then resolving an identifier
        just means registering it with all other relevant
        CoverageProviders.

        :param provider_kwargs: Pass this object in as provider_kwargs
        when calling gather_providers at the end of the
        constructor. Used only in testing.

        """
        _db = Session.object_session(collection)

        # Since we are the metadata wrangler, any resources we find,
        # we mirror using the sitewide MirrorUploader.
        if not mirror:
            try:
                mirror = MirrorUploader.sitewide(_db)
            except CannotLoadConfiguration, e:
                logging.error(
                    "No storage integration is configured. Cover images will not be stored anywhere.",
                    exc_info=e)
 def _default_replacement_policy(self, _db):
     """In general, data used by the metadata wrangler is a reliable source
     of metadata but not of licensing information. We always
     provide the MirrorUploader in case a data source has cover
     images available.
     """
     try:
         mirror = MirrorUploader.sitewide(_db)
     except CannotLoadConfiguration, e:
         # It's not a problem if there's no MirrorUploader
         # configured -- it just means we can't mirror cover images
         # when they show up.
         mirror = None
 def _default_replacement_policy(self, _db):
     """In general, data used by the metadata wrangler is a reliable source
     of metadata but not of licensing information. We always
     provide the MirrorUploader in case a data source has cover
     images available.
     """
     try:
         mirror = MirrorUploader.sitewide(_db)
     except CannotLoadConfiguration, e:
         # It's not a problem if there's no MirrorUploader
         # configured -- it just means we can't mirror cover images
         # when they show up.
         mirror = None
Ejemplo n.º 4
0
    def __init__(self, collection, mirror=None, http_get=None, viaf=None,
                 provide_coverage_immediately=False, force=False,
                 provider_kwargs=None, **kwargs
    ):
        """Constructor.

        :param collection: Handle all Identifiers from this Collection
        that were previously registered with this CoverageProvider.

        :param mirror: A MirrorUploader to use if coverage requires
        uploading any cover images to external storage.

        :param http_get: A drop-in replacement for
        Representation.simple_http_get, to be used if any information
        (such as a book cover) needs to be obtained from the public
        Internet.

        :param viaf_client: A VIAFClient to use if coverage requires
        gathering information about authors from VIAF.

        :param force: Force CoverageProviders to cover identifiers
        even if they believe they have already done the work.

        :param provide_coverage_immediately: If this is True, then
        resolving an identifier means registering it with all of its
        other CoverageProviders *and then attempting to provide
        coverage*.  Registration is considered a success even if the
        other CoverageProviders fail, but the attempt must be made
        immediately.

        If this is False (the default), then resolving an identifier
        just means registering it with all other relevant
        CoverageProviders.

        :param provider_kwargs: Pass this object in as provider_kwargs
        when calling gather_providers at the end of the
        constructor. Used only in testing.

        """
        _db = Session.object_session(collection)

        # Since we are the metadata wrangler, any resources we find,
        # we mirror using the sitewide MirrorUploader.
        if not mirror:
            try:
                mirror = MirrorUploader.sitewide(_db)
            except CannotLoadConfiguration, e:
                logging.error(
                    "No storage integration is configured. Cover images will not be stored anywhere.",
                    exc_info=e
                )
    def __init__(self, collection, *args, **kwargs):
        _db = Session.object_session(collection)

        replacement_policy = kwargs.pop('replacement_policy', None)
        if not replacement_policy:
            mirror = MirrorUploader.sitewide(_db)
            replacement_policy = ReplacementPolicy(
                mirror=mirror, links=True
            )

        # Only process identifiers that have been registered for coverage.
        kwargs['registered_only'] = kwargs.get('registered_only', True)
        super(IntegrationClientCoverImageCoverageProvider, self).__init__(
            collection, *args, replacement_policy=replacement_policy, **kwargs
        )
    def __init__(self, collection, *args, **kwargs):
        _db = Session.object_session(collection)

        replacement_policy = kwargs.pop('replacement_policy', None)
        if not replacement_policy:
            mirror = MirrorUploader.sitewide(_db)
            replacement_policy = ReplacementPolicy(mirror=mirror, links=True)

        # Only process identifiers that have been registered for coverage.
        kwargs['registered_only'] = kwargs.get('registered_only', True)
        super(IntegrationClientCoverImageCoverageProvider,
              self).__init__(collection,
                             *args,
                             replacement_policy=replacement_policy,
                             **kwargs)