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

Adding 'CreateSpace Independent Publishing Platform' to the list of independent publishers that should not be imported. #10158

Merged
merged 1 commit into from
Dec 17, 2024
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
14 changes: 12 additions & 2 deletions openlibrary/catalog/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,20 @@ def source_requires_date_validation(rec: dict) -> bool:
def is_independently_published(publishers: list[str]) -> bool:
"""
Return True if the book is independently published.

"""
independent_publisher_names = ['independently published', 'independent publisher']
independent_publisher_names = [
'independently published',
'independent publisher',
'createspace independent publishing platform',
]

independent_publisher_names_casefolded = [
name.casefold() for name in independent_publisher_names
]
return any(
publisher.casefold() in independent_publisher_names for publisher in publishers
publisher.casefold() in independent_publisher_names_casefolded
for publisher in publishers
)


Expand Down
2 changes: 2 additions & 0 deletions openlibrary/tests/catalog/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,10 @@ def test_publication_too_old_and_not_exempt(name, rec, expected) -> None:
[
(['INDEPENDENTLY PUBLISHED'], True),
(['Independent publisher'], True),
(['createspace independent publishing platform'], True),
(['Another Publisher', 'independently published'], True),
(['Another Publisher', 'independent publisher'], True),
(['Another Publisher', 'createspace independent publishing platform'], True),
(['Another Publisher'], False),
],
)
Expand Down
Loading