23 lines
572 B
Python
23 lines
572 B
Python
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}%" |