implementation to pass tests
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
DEV_MODE = False
|
||||
MAIN_LOGGER_NAME = 'mwfin'
|
||||
|
||||
HTML_PARSER = 'html.parser'
|
||||
|
@ -9,6 +9,7 @@ from webutils import in_async_session, gather_in_batches
|
||||
|
||||
from .constants import (HTML_PARSER, BASE_URL, END_DATE, BS, IS, CF, FIN_STMT_URL_SUFFIX, FIN_STMT_ITEMS,
|
||||
DEFAULT_CONCURRENT_BATCH_SIZE)
|
||||
from .exceptions import UnknownFinancialStatementItem
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -48,15 +49,21 @@ def is_relevant_table_row(tr: Tag) -> bool:
|
||||
return FIN_STMT_ITEMS[item_name]
|
||||
except KeyError:
|
||||
log.warning(f"Unknown item name '{item_name}' found in financial statement.")
|
||||
return False
|
||||
raise UnknownFinancialStatementItem
|
||||
|
||||
|
||||
def find_relevant_table_rows(soup: BeautifulSoup) -> List[Tag]:
|
||||
"""
|
||||
Returns the table rows containing the data of interest.
|
||||
"""
|
||||
trs = soup.find('div', attrs={'class': 'financials'}).tbody.find_all('tr')
|
||||
return [tr for tr in trs if is_relevant_table_row(tr)]
|
||||
trs = []
|
||||
for tr in soup.find('div', attrs={'class': 'financials'}).tbody.find_all('tr'):
|
||||
try:
|
||||
if is_relevant_table_row(tr):
|
||||
trs.append(tr)
|
||||
except UnknownFinancialStatementItem:
|
||||
pass
|
||||
return trs
|
||||
|
||||
|
||||
def extract_row_data(tr: Tag) -> tuple[str, tuple[int]]:
|
||||
|
Reference in New Issue
Block a user