Added Application HolidayViewer
This commit is contained in:
@@ -8,9 +8,12 @@ import types
|
||||
import uuid
|
||||
from enum import Enum
|
||||
from io import BytesIO
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from constants import SESSION_USER_ID_KEY, NOT_LOGGED, NO_SESSION
|
||||
|
||||
PRIMITIVES = (str, bool, type(None), int, float)
|
||||
|
||||
|
||||
@@ -378,3 +381,39 @@ def merge_classes(*args):
|
||||
return " ".join(unique_elements)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def get_user_id(session: dict | None):
|
||||
return str(session.get(SESSION_USER_ID_KEY, NOT_LOGGED)) if session is not None else NO_SESSION
|
||||
|
||||
|
||||
def split_host_port(url):
|
||||
"""
|
||||
Split a URL into host and port components.
|
||||
|
||||
Args:
|
||||
url (str): The full URL to split
|
||||
|
||||
Returns:
|
||||
tuple: (host, port) where port is an integer if specified, otherwise None
|
||||
"""
|
||||
parsed_url = urlparse(url)
|
||||
|
||||
# Get netloc (host:port part)
|
||||
netloc = parsed_url.netloc
|
||||
|
||||
# Split netloc by ':' to separate host and port
|
||||
if ':' in netloc:
|
||||
host, port_str = netloc.split(':', 1)
|
||||
port = int(port_str)
|
||||
else:
|
||||
host = netloc
|
||||
# Use default ports based on scheme if port is not specified
|
||||
if parsed_url.scheme == 'http':
|
||||
port = 80
|
||||
elif parsed_url.scheme == 'https':
|
||||
port = 443
|
||||
else:
|
||||
port = None
|
||||
|
||||
return host, port
|
||||
|
||||
Reference in New Issue
Block a user