-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from uktrade/feature/orpd-33-backend-services
Feature/orpd 33 backend services
- Loading branch information
Showing
15 changed files
with
7,983 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class SearchDocumentConfig: | ||
def __init__( | ||
self, search_terms: str, document_types=None, timeout=None, dummy=False | ||
): | ||
""" | ||
Initializes a new instance of the class. | ||
:param searchTerms: A comma-separated string of search terms. | ||
:param documentTypes: Optional. A list of document types | ||
to filter the search. | ||
:param timeout: Optional. The timeout in seconds for the search | ||
request. | ||
""" | ||
self.search_terms = [term.strip() for term in search_terms.split(",")] | ||
self.document_types = document_types | ||
self.timeout = None if timeout is None else int(timeout) | ||
self.dummy = dummy | ||
|
||
def validate(self): | ||
""" | ||
Validates the presence of search terms. | ||
Checks if the 'searchTerms' attribute exists and is non-empty. Logs | ||
an error message and returns False if 'searchTerms' is missing or | ||
empty. | ||
Returns | ||
------- | ||
bool | ||
True if 'searchTerms' is present and non-empty, False otherwise. | ||
""" | ||
if not self.search_terms: | ||
logger.error("search terms are required") | ||
return False | ||
return True |
Oops, something went wrong.