dataset/seed/base/funcs/base.py

27 lines
814 B
Python
Raw Normal View History

2022-06-29 11:44:01 +02:00
from typing import List
from risotto.utils import load_domains, DOMAINS
2022-08-18 10:19:43 +02:00
from risotto.utils import multi_function as _multi_function
2022-06-29 11:44:01 +02:00
2022-08-18 10:19:43 +02:00
@_multi_function
2022-06-29 11:44:01 +02:00
def get_ip(server_name: str) -> str:
2022-08-18 10:19:43 +02:00
if server_name is None:
return
if isinstance(server_name, list):
return_list = True
else:
return_list = False
server_name = [server_name]
lst = []
for s_name in server_name:
host_name, domain_name = s_name.split('.', 1)
if not domain_name in DOMAINS:
raise ValueError(f'cannot find IP in domain name "{domain_name}" (for "{s_name}")')
domain = DOMAINS[domain_name]
ret = domain[1][domain[0].index(host_name)]
if not return_list:
return ret
if ret not in lst:
lst.append(ret)
return lst