Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused class OPDSImportCoverageProvider (PP-313) #1393

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 0 additions & 147 deletions api/coverage.py

This file was deleted.

55 changes: 0 additions & 55 deletions core/opds_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@

from api.circulation import CirculationConfigurationMixin
from api.selftest import HasCollectionSelfTests
from core.integration.goals import Goals
from core.integration.settings import (
BaseSettings,
ConfigurationFormItem,
ConfigurationFormItemType,
FormField,
)
from core.model.integration import IntegrationConfiguration

from .classifier import Classifier
from .config import IntegrationException
Expand Down Expand Up @@ -95,59 +93,6 @@ def parse_identifier(db, identifier):
return parsed_identifier


class AccessNotAuthenticated(Exception):
"""No authentication is configured for this service"""


class SimplifiedOPDSLookup:
"""Tiny integration class for the Simplified 'lookup' protocol."""

LOOKUP_ENDPOINT = "lookup"

@classmethod
def check_content_type(cls, response):
content_type = response.headers.get("content-type")
if content_type != OPDSFeed.ACQUISITION_FEED_TYPE:
raise BadResponseException.from_response(
response.url, "Wrong media type: %s" % content_type, response
)

@classmethod
def from_protocol(cls, _db, protocol, goal=Goals.LICENSE_GOAL, library=None):
config = get_one(_db, IntegrationConfiguration, protocol=protocol, goal=goal)
if config is not None and library is not None:
config = config.for_library(library.id)
if config is None:
return None
return cls(config.settings_dict["url"])

def __init__(self, base_url):
if not base_url.endswith("/"):
base_url += "/"
self.base_url = base_url

@property
def lookup_endpoint(self):
return self.LOOKUP_ENDPOINT

def _get(self, url, **kwargs):
"""Make an HTTP request. This method is overridden in the mock class."""
kwargs["timeout"] = kwargs.get("timeout", 300)
kwargs["allowed_response_codes"] = kwargs.get("allowed_response_codes", [])
kwargs["allowed_response_codes"] += ["2xx", "3xx"]
return HTTP.get_with_timeout(url, **kwargs)

def urn_args(self, identifiers):
return "&".join({"urn=%s" % i.urn for i in identifiers})

def lookup(self, identifiers):
"""Retrieve an OPDS feed with metadata for the given identifiers."""
args = self.urn_args(identifiers)
url = self.base_url + self.lookup_endpoint + "?" + args
logging.info("Lookup URL: %s", url)
return self._get(url)


class OPDSXMLParser(XMLParser):
NAMESPACES = {
"simplified": "http://librarysimplified.org/terms/",
Expand Down
23 changes: 0 additions & 23 deletions tests/api/mockapi/opds.py

This file was deleted.

Loading