|
7 | 7 | import requests |
8 | 8 |
|
9 | 9 | from 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_warning, log_error |
11 | 11 | from ted_sws.notice_fetcher.adapters.ted_api_abc import TedAPIAdapterABC, RequestAPI |
12 | 12 |
|
13 | 13 | DOCUMENTS_PER_PAGE = 100 |
@@ -103,18 +103,11 @@ def _retrieve_document_content(self, document_content: dict) -> str: |
103 | 103 | :return:str ' |
104 | 104 | """ |
105 | 105 | 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] |
118 | 111 | response = requests.get(xml_document_content_link) |
119 | 112 | try_again_request_count = 0 |
120 | 113 | while response.status_code == HTTPStatus.TOO_MANY_REQUESTS: |
|
0 commit comments