initial commit
This commit is contained in:
23
app/misc.py
Normal file
23
app/misc.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import re
|
||||
|
||||
# Constants
|
||||
PROGRESS_BAR_LENGTH = 10
|
||||
|
||||
def extract_url_from_string(text: str):
|
||||
"""
|
||||
Extracts the first URL from a string
|
||||
"""
|
||||
|
||||
url_pattern = re.compile(r'https?://\S+')
|
||||
match = url_pattern.search(text)
|
||||
|
||||
if match:
|
||||
return match.group(0)
|
||||
else:
|
||||
return None
|
||||
|
||||
def render_progress_bar(percent: int, length: int = PROGRESS_BAR_LENGTH) -> str:
|
||||
"""Renders a progress bar with the given percentage."""
|
||||
filled = int(length * percent // 100)
|
||||
bar = "█" * filled + " " * (length - filled)
|
||||
return f"[{bar}] {percent}%"
|
Reference in New Issue
Block a user