refactor: simplify load_html_from_file function and add debug prints in Reports class

- Removed exception handling in load_html_from_file for cleaner code.
- Added debug print statements in the Reports class to log output directory, report path, and base path for better traceability during report generation.
This commit is contained in:
vitor-aignosi
2026-04-16 14:17:54 -03:00
parent 17632477a8
commit b2458ec354

View File

@@ -33,14 +33,8 @@ COLOR_DISCRETE_SEQUENCE = (
def load_html_from_file(file_path): def load_html_from_file(file_path):
try: with open(file_path, encoding='utf-8') as file:
with open(file_path, encoding='utf-8') as file: return file.read()
return file.read()
except FileNotFoundError:
return None
except OSError: # noqa: BLE001
return None
def inject_content(main_html, section_id, content): def inject_content(main_html, section_id, content):
soup = BeautifulSoup(main_html, 'html.parser') soup = BeautifulSoup(main_html, 'html.parser')
@@ -249,6 +243,10 @@ class Reports:
if output_dir and not os.path.exists(output_dir): if output_dir and not os.path.exists(output_dir):
os.makedirs(output_dir, exist_ok=True) os.makedirs(output_dir, exist_ok=True)
print(f"Output directory: {output_dir}")
print(f"Report path: {report_path}")
print(f"Base path: {self.base_path}")
# Load main HTML template # Load main HTML template
main_html_path = os.path.join(self.base_path, 'header.html') main_html_path = os.path.join(self.base_path, 'header.html')
main_html = load_html_from_file(main_html_path) main_html = load_html_from_file(main_html_path)