Squashed 'utils_v2/' content from commit 62600ef

git-subtree-dir: utils_v2
git-subtree-split: 62600ef57051e69587da18015b7b6840fdac3194
This commit is contained in:
2025-11-14 17:00:28 +05:30
commit 7fdd2411bb
227 changed files with 151811 additions and 0 deletions
+102
View File
@@ -0,0 +1,102 @@
"""
AUTHOR:
Khushal P Soonderji
DATE:
Tuesday, 14th Oct., 2025.
OBJECTIVE:
To provide a standard logo that can be rendered from anywhere.
REFERENCES:
1) https://docs.streamlit.io/develop/api-reference
DOWNLOADS:
N/A
"""
# *****************************************************************************************************************
# ***** ****
# *** IMPORT ***
# ***** ****
# *****************************************************************************************************************
# To make sibling directories accessible for imports:
import sys
sys.path.append(".")
sys.path.append("..")
# Streamlit:
import streamlit as st
# For working with datatypes:
from typing import Literal
# *****************************************************************************************************************
# ***** ****
# *** MACROS / ONE-TIME INIT ***
# ***** ****
# *****************************************************************************************************************
# --- Nothing Yet
# *****************************************************************************************************************
# ***** ****
# *** VARIABLES ***
# ***** ****
# *****************************************************************************************************************
# --- Nothing Yet
# *****************************************************************************************************************
# ***** ****
# *** FUNCTIONS ***
# ***** ****
# *****************************************************************************************************************
def draw(
full_image: str,
icon_image: str,
size: Literal["small", "medium", "large"] = "large",
) -> None:
"""
Draws the logo of the site with the provided inputs.
:param full_image: The full-sized image to when the sidebar is open.
:param icon_image: The icon-size image to use when the sidebar is closed.
:param size: The desired size of the logo.
:return: None.
"""
st.logo(
image = full_image,
icon_image = icon_image,
size = size
)
# *****************************************************************************************************************
# ***** ****
# *** MAIN PROGRAM ***
# ***** ****
# *****************************************************************************************************************
if __name__ == "__main__":
pass
+127
View File
@@ -0,0 +1,127 @@
"""
AUTHOR:
Khushal P Soonderji
DATE:
Friday, 10th Jan., 2025
OBJECTIVE:
To provide a typewriter style effect for any text.
REFERENCES:
N/A
DOWNLOADS:
N/A
"""
# *****************************************************************************************************************
# ***** ****
# *** IMPORT ***
# ***** ****
# *****************************************************************************************************************
# To make sibling directories accessible for imports:
import sys
sys.path.append("..")
sys.path.append("../..")
# Streamlit:
import streamlit as st
# To work with date and time:
import time
# *****************************************************************************************************************
# ***** ****
# *** MACROS / ONE-TIME INIT ***
# ***** ****
# *****************************************************************************************************************
# --- Nothing Yet
# *****************************************************************************************************************
# ***** ****
# *** VARIABLES ***
# ***** ****
# *****************************************************************************************************************
# --- Nothing Yet
# *****************************************************************************************************************
# ***** ****
# *** FUNCTIONS ***
# ***** ****
# *****************************************************************************************************************
def generate_text(
text: str,
chunk_size: int = 1,
chunk_delay: float = 0.025
) -> str:
"""
Generates a character stream from a given text to display it through 'st.write_stream'.
:param text: The text that you want to display
:param chunk_size: How many chars to yield in every iteration.
:param chunk_delay: How many seconds to wait before giving out the next chunk.
:return: The chunks of the input text.
"""
chunks = [text[i:i + chunk_size] for i in range(0, len(text), chunk_size)]
for chunk in chunks:
time.sleep(chunk_delay)
yield chunk
# ---------------------------------------------------------------------------------------------------------------------
def draw(
text: str,
chunk_size: int = 1,
chunk_delay: float = 0.025
) -> None:
"""
Writes text in a typewriter style.
:param text: The text that you want to display
:param chunk_size: How many chars to yield in every iteration.
:param chunk_delay: How many seconds to wait before giving out the next chunk.
:return: None.
"""
st.write_stream(
stream = generate_text(
text = text,
chunk_size = chunk_size,
chunk_delay = chunk_delay
)
)
# *****************************************************************************************************************
# ***** ****
# *** MAIN PROGRAM ***
# ***** ****
# *****************************************************************************************************************
if __name__ == "__main__":
pass