04/23 Fixed bugs
This commit is contained in:
@@ -352,8 +352,13 @@ class WebsiteDialog(tk.Toplevel):
|
||||
def _on_visibility_change(self):
|
||||
"""Show or hide the user assignment panel based on visibility selection."""
|
||||
if self.visibility_var.get() == "assigned":
|
||||
# Use before=self._cred_body (not self.creds_container) because
|
||||
# pack's `before` argument requires the reference widget to share
|
||||
# the same parent. _user_assign_frame and _cred_body are both
|
||||
# children of self.inner; creds_container is a child of _cred_body,
|
||||
# so referencing it across that boundary raises a TclError.
|
||||
self._user_assign_frame.pack(fill="x", padx=24, pady=(0, 4),
|
||||
before=self.creds_container)
|
||||
before=self._cred_body)
|
||||
else:
|
||||
self._user_assign_frame.pack_forget()
|
||||
|
||||
|
||||
@@ -851,17 +851,32 @@ def _read_doc(path: str) -> str:
|
||||
|
||||
|
||||
def _read_excel(path: str) -> str:
|
||||
"""
|
||||
Extract text from an Excel file via openpyxl (read-only mode).
|
||||
Iteration stops as soon as accumulated content exceeds MAX_CHARS_PER_FILE
|
||||
to avoid loading the entire workbook into memory for very large files.
|
||||
The AI layer will truncate to MAX_CHARS_PER_FILE anyway, so there is no
|
||||
value in continuing past that point.
|
||||
"""
|
||||
MAX_CHARS_PER_FILE = 14_000 # mirror the constant in AiSummaryView._run_ai
|
||||
try:
|
||||
import openpyxl
|
||||
wb = openpyxl.load_workbook(path, read_only=True, data_only=True)
|
||||
lines = []
|
||||
total_chars = 0
|
||||
for sheet in wb.worksheets:
|
||||
lines.append(f"[Sheet: {sheet.title}]")
|
||||
header = f"[Sheet: {sheet.title}]"
|
||||
lines.append(header)
|
||||
total_chars += len(header) + 1
|
||||
for row in sheet.iter_rows(values_only=True):
|
||||
row_str = "\t".join(
|
||||
str(v) if v is not None else "" for v in row)
|
||||
if row_str.strip():
|
||||
lines.append(row_str)
|
||||
total_chars += len(row_str) + 1
|
||||
if total_chars >= MAX_CHARS_PER_FILE:
|
||||
lines.append("[... content truncated to fit token limit ...]")
|
||||
return "\n".join(lines)
|
||||
return "\n".join(lines)
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
|
||||
Reference in New Issue
Block a user