Skip to content

Commit 05c4139

Browse files
author
enryh
committed
🐛 strip unicode in case not supported on os
1 parent faa8fc4 commit 05c4139

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

src/vuegen/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def main():
4848
)
4949

5050
# Print completion message
51-
# print_completion_message(report_type) # ! test if message is an issue on windows
51+
print_completion_message(report_type) # ! test if message is an issue on windows
5252

5353

5454
if __name__ == "__main__":

src/vuegen/utils.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import logging
66
import os
77
import sys
8+
import unicodedata
89
from datetime import datetime
910

1011
try:
@@ -729,14 +730,31 @@ def get_logger(log_suffix):
729730
return logger
730731

731732

733+
def strip_unicode(text: str) -> str:
734+
"""
735+
Strip Unicode characters from the given text.
736+
737+
Parameters
738+
----------
739+
text : str
740+
The input text from which to strip Unicode characters.
741+
742+
Returns
743+
-------
744+
str
745+
The text with Unicode characters removed.
746+
"""
747+
return "".join(c for c in text if ord(c) < 128)
748+
749+
732750
def print_completion_message(report_type: str):
733751
"""
734752
Prints a formatted completion message after report generation.
735753
"""
736754
border = "─" * 65 # Creates a separator line
737755
if report_type == "streamlit":
738-
print(
739-
"""🚀 Streamlit Report Generated!
756+
msg = """
757+
🚀 Streamlit Report Generated!
740758
741759
📂 All scripts to build the Streamlit app are available at:
742760
streamlit_report/sections
@@ -749,10 +767,9 @@ def print_completion_message(report_type: str):
749767
🛠️ Advanced users can modify the Python scripts directly in:
750768
streamlit_report/sections
751769
"""
752-
)
753770
else:
754-
print(
755-
f"""🚀 {report_type.capitalize()} Report Generated!
771+
msg = f"""
772+
🚀 {report_type.capitalize()} Report Generated!
756773
757774
📂 Your {report_type} report is available at:
758775
quarto_report
@@ -762,8 +779,11 @@ def print_completion_message(report_type: str):
762779
🛠️ Advanced users can modify the report template directly in:
763780
quarto_report/quarto_report.qmd
764781
"""
765-
)
766-
782+
try:
783+
print(msg)
784+
except UnicodeEncodeError:
785+
msg = strip_unicode(msg)
786+
print(msg)
767787
print(border)
768788

769789

0 commit comments

Comments
 (0)