Skip to content

Commit c43dc8f

Browse files
committed
Convert the Bibliotheca integration into a package
The Bibliotheca integration was five flat bibliotheca_* modules sitting directly in integration/license/, while every other integration (overdrive/, boundless/, opds/) is a package. Restructure it to match. The five modules become bibliotheca/{api,importer,purchase_record_importer, circulation_updater,scripts}.py, and the 1295-line api.py is split along the same seams the siblings use: settings.py (as in overdrive and boundless), parser.py (as in boundless), and coverage.py (as in overdrive). Splitting the parsers out exposed a cycle: BibliothecaAPI constructs the parsers, but ErrorParser, EventParser and PatronCirculationParser reached back for BibliothecaAPI.SERVICE_NAME and .ARGUMENT_TIME_FORMAT. Add a constants.py holding those values and point the parsers at it, mirroring how boundless/parser.py and overdrive/coverage.py already avoid the same cycle. BibliothecaAPI keeps both class attributes, so nothing that reads them off the API changes. Also drop EventParser.EVENT_SOURCE and EventParser.SET_DELIVERY_MECHANISM_AT. Both were unread: EVENT_SOURCE has no readers anywhere, and the two sites that read SET_DELIVERY_MECHANISM_AT do so off a BaseCirculationAPI, which EventParser is not. Removing them lets parser.py stop importing the circulation API layer entirely. BibliothecaAPI.SET_DELIVERY_MECHANISM_AT is a different attribute on a different class and is untouched. Mirror the layout in tests/, moving the fixture into a conftest.py as boundless does. TestBibliographicCoverageProvider subclassed TestBibliothecaAPI without using anything from it, which made pytest re-run all 22 API tests a second time; it no longer does. All 38 declared tests are preserved, with test_internal_formats moving to TestItemListParser, the class it actually exercises.
1 parent ff7fa19 commit c43dc8f

41 files changed

Lines changed: 2129 additions & 2028 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bin/bibliotheca_circulation_update

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
"""Manually kick off the Bibliotheca circulation update for one or all collections."""
3-
from palace.manager.integration.license.bibliotheca_scripts import (
3+
from palace.manager.integration.license.bibliotheca.scripts import (
44
CirculationUpdateCollection,
55
)
66

bin/bibliotheca_import

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
"""Manually kick off the Bibliotheca event import for one or all collections."""
33

4-
from palace.manager.integration.license.bibliotheca_scripts import (
4+
from palace.manager.integration.license.bibliotheca.scripts import (
55
ImportEventCollection,
66
)
77

bin/bibliotheca_purchase_record_import

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
"""Manually kick off the Bibliotheca purchase record import for one or all collections."""
33

4-
from palace.manager.integration.license.bibliotheca_scripts import (
4+
from palace.manager.integration.license.bibliotheca.scripts import (
55
ImportPurchaseRecordCollection,
66
)
77

bin/informational/bibliotheca-raw-bibliographic

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
from xml.dom import minidom
33

4-
from palace.manager.integration.license.bibliotheca import BibliothecaAPI
4+
from palace.manager.integration.license.bibliotheca.api import BibliothecaAPI
55
from palace.manager.scripts.input import IdentifierInputScript
66
from palace.manager.sqlalchemy.model.collection import Collection
77

bin/informational/bibliotheca-raw-patron-status

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
from xml.dom import minidom
44

5-
from palace.manager.integration.license.bibliotheca import BibliothecaAPI
5+
from palace.manager.integration.license.bibliotheca.api import BibliothecaAPI
66
from palace.manager.scripts.base import Script
77
from palace.manager.sqlalchemy.model.collection import Collection
88
from palace.manager.sqlalchemy.model.patron import Patron

bin/repair/bibliotheca_bibliographic_coverage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""Make sure all Bibliotheca books have bibliographic coverage."""
33

44

5-
from palace.manager.integration.license.bibliotheca import (
5+
from palace.manager.integration.license.bibliotheca.coverage import (
66
BibliothecaBibliographicCoverageProvider,
77
)
88
from palace.manager.scripts.coverage_provider import RunCollectionCoverageProviderScript

src/palace/manager/celery/tasks/bibliotheca.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@
3232
from palace.manager.celery.importer import workflow_lock_guard
3333
from palace.manager.celery.task import Task
3434
from palace.manager.celery.utils import ModelNotFoundError, load_from_id, signature_with
35-
from palace.manager.integration.license.bibliotheca import BibliothecaAPI
36-
from palace.manager.integration.license.bibliotheca_circulation_updater import (
35+
from palace.manager.integration.license.bibliotheca.api import BibliothecaAPI
36+
from palace.manager.integration.license.bibliotheca.circulation_updater import (
3737
BibliothecaCirculationUpdater,
3838
)
39-
from palace.manager.integration.license.bibliotheca_importer import (
39+
from palace.manager.integration.license.bibliotheca.importer import (
4040
EVENT_IMPORT_OVERLAP,
4141
BibliothecaEventImporter,
4242
)
43-
from palace.manager.integration.license.bibliotheca_purchase_record_importer import (
43+
from palace.manager.integration.license.bibliotheca.purchase_record_importer import (
4444
DEFAULT_PURCHASE_RECORD_START_TIME,
4545
PURCHASE_RECORD_SERVICE_NAME,
4646
BibliothecaPurchaseRecordImporter,

0 commit comments

Comments
 (0)