17 lines
618 B
Python
17 lines
618 B
Python
|
|
import os
|
|
from typing import Tuple
|
|
|
|
def get_api_host(region: str) -> str:
|
|
return f"https://{region}.api.blizzard.com" if region != 'cn' else 'https://gateway.battlenet.com.cn'
|
|
|
|
def get_bnet_host(region: str) -> str:
|
|
region = region if region not in ['tw', 'kr'] else 'apac'
|
|
return f"https://{region}.battle.net" if region != 'cn' else 'https://www.battlenet.com.cn'
|
|
|
|
def get_credentials(path: str) -> Tuple[str, str]:
|
|
return tuple(open(os.path.join(path, '.credentials')).read().strip().split(':'))
|
|
|
|
def get_by_key(values: list, key: str, value):
|
|
return next(x for x in values if x[key] == value)
|