Skip to content

Commit 33333d2

Browse files
remove fallback for MUL language key
1 parent 4ced645 commit 33333d2

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

ted_sws/notice_fetcher/adapters/ted_api.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import requests
88

99
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
1111
from ted_sws.notice_fetcher.adapters.ted_api_abc import TedAPIAdapterABC, RequestAPI
1212

1313
DOCUMENTS_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:

0 commit comments

Comments
 (0)