2023-02-14 14:24:16 +01:00
|
|
|
def calc_web_address(domain_name: str,
|
|
|
|
port: str,
|
|
|
|
local_location: str,
|
|
|
|
http: bool,
|
|
|
|
) -> str:
|
2022-03-08 19:42:28 +01:00
|
|
|
if not domain_name or not port:
|
|
|
|
return
|
2023-02-14 14:24:16 +01:00
|
|
|
if http:
|
|
|
|
web_address = f'http://{domain_name}'
|
|
|
|
test_port = '80'
|
|
|
|
else:
|
|
|
|
web_address = f'https://{domain_name}'
|
|
|
|
test_port = '443'
|
|
|
|
if port != test_port:
|
2022-03-20 21:15:45 +01:00
|
|
|
web_address += f':{port}'
|
2022-03-08 19:42:28 +01:00
|
|
|
if local_location:
|
|
|
|
web_address += local_location
|
|
|
|
return web_address
|
2022-05-23 08:49:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
def get_first_value(lst: list):
|
|
|
|
if lst:
|
2023-01-17 21:43:32 +01:00
|
|
|
if isinstance(lst[0], list):
|
|
|
|
if lst[0] and lst[0][0]:
|
|
|
|
return lst[0][0]
|
|
|
|
else:
|
|
|
|
return lst[0]
|