def find_total_work_duration(
worksheet: Worksheet,
*,
data_first_row: int,
total_work_duration_label: str,
) -> Tuple[Optional[int], str, Optional[int]]:
"""
Ищет строку "Суммарное время работы:" и парсит длительность рядом.
Возвращает (секунды, сырое значение ячейки, номер строки с меткой) или (None, "", None).
"""
for row_index, row_values in enumerate(
worksheet.iter_rows(min_row=data_first_row, values_only=True),
start=data_first_row,
):
for column_index, cell_value in enumerate(row_values):
if cell_value is None:
continue
cell_text = _stringify_cell(cell_value).strip()
if total_work_duration_label not in cell_text:
continue
duration_candidates = []
if column_index + 1 < len(row_values):
duration_candidates.append(row_values[column_index + 1])
if row_index + 1 <= worksheet.max_row:
duration_candidates.append(
worksheet.cell(row=row_index + 1, column=column_index + 1).value
)
for candidate in duration_candidates:
duration_seconds = parse_duration_seconds(candidate)
if duration_seconds is not None:
return duration_seconds, _stringify_cell(candidate).strip(), row_index
return None, "", row_index
return None, "", None
total_duration_seconds, total_duration_raw, total_label_row_index =
total_duration_seconds, total_duration_raw, total_label_row_index = find_total_work_duration(
worksheet,
data_first_row=LdsReportConst.REPORT_DATA_FIRST_ROW,
total_work_duration_label=LdsReportConst.TOTAL_WORK_DURATION_LABEL,
)
"LdsStatusReportSectionRow",
"find_total_work_duration",