Skip to content

Commit

Permalink
Adding "CreateSpace Independent Publishing Platform" to the list of i…
Browse files Browse the repository at this point in the history
…ndependent publishers not to be imported. (#10158)
  • Loading branch information
DebbieSan authored Dec 17, 2024
1 parent a4e6bcc commit 4b27f57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
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

0 comments on commit 4b27f57

Please sign in to comment.