File tree Expand file tree Collapse file tree
ted_sws/notice_fetcher/adapters Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77import requests
88
99from ted_sws import config
10- from ted_sws .event_manager .services .log import log_warning
10+ from ted_sws .event_manager .services .log import log_error
1111from ted_sws .notice_fetcher .adapters .ted_api_abc import TedAPIAdapterABC , RequestAPI
1212
1313DOCUMENTS_PER_PAGE = 100
@@ -103,18 +103,11 @@ def _retrieve_document_content(self, document_content: dict) -> str:
103103 :return:str '
104104 """
105105 xml_links = document_content [LINKS_TO_CONTENT_KEY ][XML_CONTENT_KEY ]
106- language_key = MULTIPLE_LANGUAGE_CONTENT_KEY
107- if language_key not in xml_links .keys ():
108- if ENGLISH_LANGUAGE_CONTENT_KEY in xml_links .keys ():
109- language_key = ENGLISH_LANGUAGE_CONTENT_KEY
110- else :
111- language_key = xml_links .keys ()[0 ]
112-
113- log_warning (
114- f"Language key { MULTIPLE_LANGUAGE_CONTENT_KEY } not found in { document_content [DOCUMENT_NOTICE_ID_KEY ]} ,"
115- f" and will be used language key { language_key } !" )
116-
117- xml_document_content_link = xml_links [language_key ]
106+ if MULTIPLE_LANGUAGE_CONTENT_KEY not in xml_links .keys ():
107+ exception_message = f"Language key { MULTIPLE_LANGUAGE_CONTENT_KEY } not found in { document_content [DOCUMENT_NOTICE_ID_KEY ]} "
108+ log_error (exception_message )
109+ raise Exception (exception_message )
110+ xml_document_content_link = xml_links [MULTIPLE_LANGUAGE_CONTENT_KEY ]
118111 response = requests .get (xml_document_content_link )
119112 try_again_request_count = 0
120113 while response .status_code == HTTPStatus .TOO_MANY_REQUESTS :
You can’t perform that action at this time.
0 commit comments