|
1 | 1 | import os |
2 | | -import re |
3 | 2 | import subprocess |
4 | 3 | import sys |
| 4 | +import textwrap |
5 | 5 | from pathlib import Path |
6 | 6 | from typing import List |
7 | 7 |
|
@@ -75,16 +75,29 @@ def generate_report( |
75 | 75 | self.report.logger.debug("Processing app navigation code.") |
76 | 76 | # Define the Streamlit imports and report manager content |
77 | 77 | report_manag_content = [] |
| 78 | + report_manag_content.append( |
| 79 | + textwrap.dedent( |
| 80 | + """\ |
| 81 | + import streamlit as st |
| 82 | + """ |
| 83 | + ) |
| 84 | + ) |
78 | 85 | if self.report.logo: |
79 | 86 | report_manag_content.append( |
80 | | - f"""import streamlit as st\n |
81 | | -st.set_page_config(layout="wide", page_title="{self.report.title}", page_icon="{self.report.logo}") |
82 | | -st.logo("{self.report.logo}")""" |
| 87 | + textwrap.dedent( |
| 88 | + f"""\ |
| 89 | + st.set_page_config(layout="wide", page_title="{self.report.title}", page_icon="{self.report.logo}") |
| 90 | + st.logo("{self.report.logo}") |
| 91 | + """ |
| 92 | + ) |
83 | 93 | ) |
84 | 94 | else: |
85 | 95 | report_manag_content.append( |
86 | | - f"""import streamlit as st\n |
87 | | -st.set_page_config(layout="wide", page_title="{self.report.title}")""" |
| 96 | + textwrap.dedent( |
| 97 | + f"""\ |
| 98 | + st.set_page_config(layout="wide", page_title="{self.report.title}") |
| 99 | + """ |
| 100 | + ) |
88 | 101 | ) |
89 | 102 | report_manag_content.append( |
90 | 103 | self._format_text( |
@@ -147,7 +160,9 @@ def generate_report( |
147 | 160 | ) |
148 | 161 |
|
149 | 162 | # Write the navigation and general content to a Python file |
150 | | - with open(Path(output_dir) / self.REPORT_MANAG_SCRIPT, "w") as nav_manager: |
| 163 | + with open( |
| 164 | + Path(output_dir) / self.REPORT_MANAG_SCRIPT, "w", encoding="utf8" |
| 165 | + ) as nav_manager: |
151 | 166 | nav_manager.write("\n".join(report_manag_content)) |
152 | 167 | self.report.logger.info( |
153 | 168 | f"Created app navigation script: {self.REPORT_MANAG_SCRIPT}" |
|
0 commit comments