Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
stitch committed Nov 6, 2023
1 parent d1c5a63 commit 09719be
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions dashboard/internet_nl_dashboard/logic/spreadsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ def is_valid_extension(file: str) -> bool:
return False


def get_sheet(file: str) -> List:
try:
sheet = p.get_sheet(file_name=file, name_columns_by_row=0)
except XLRDError:
# xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'thisfile'
return []
except zipfile.BadZipFile:
# the corrupted file in the unit tests
return []
except Exception as exc: # pylint: disable=broad-except
log.exception(exc)
return []

return sheet


def get_data(file: str) -> Dict[str, Dict[str, Dict[str, list]]]:
"""
Will return a simple set of data, without too much validation. Deduplicates data per unique category.
Expand All @@ -133,16 +149,8 @@ def get_data(file: str) -> Dict[str, Dict[str, Dict[str, list]]]:

data: Dict[str, Any] = {}

try:
sheet = p.get_sheet(file_name=file, name_columns_by_row=0)
except XLRDError:
# xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'thisfile'
return data
except zipfile.BadZipFile:
# the corrupted file in the unit tests
return data
except Exception as exc: # pylint: disable=broad-except
log.exception(exc)
sheet = get_sheet(file=file)
if not sheet:
return data

# Skips the first entry
Expand Down

0 comments on commit 09719be

Please sign in to comment.