From 430cfb2156dba6734772bd9bc2efb4d825237baf Mon Sep 17 00:00:00 2001 From: Debbie San Date: Tue, 17 Dec 2024 11:51:46 -0700 Subject: [PATCH] Adding CreateSpace Independent Publishing Platform" to the list of independent publishers not to be imported. --- openlibrary/catalog/utils/__init__.py | 14 ++++++++++++-- openlibrary/tests/catalog/test_utils.py | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/openlibrary/catalog/utils/__init__.py b/openlibrary/catalog/utils/__init__.py index 72df6338827..1ae0fd89048 100644 --- a/openlibrary/catalog/utils/__init__.py +++ b/openlibrary/catalog/utils/__init__.py @@ -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 ) diff --git a/openlibrary/tests/catalog/test_utils.py b/openlibrary/tests/catalog/test_utils.py index fc770d5e996..4e5d24212e0 100644 --- a/openlibrary/tests/catalog/test_utils.py +++ b/openlibrary/tests/catalog/test_utils.py @@ -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), ], )