# Path: scripts/helpers.py
# def try_divide(numerator: Union[int, float], denominator: Union[int, float]):
#     """
#     Try to divide two numbers.
#     :param numerator: the numerator.
#     :param denominator: the denominator.
#     :return: the result of the division if denominator is not zero else 0.
#     """
#     return numerator / denominator if denominator else 0


from aiohttp_wrapper import SessionManager
from wowspy import Region, WowsAsync
from scripts.helpers import try_divide
        expected = {}
        for entry in __expected:
            expected[str(entry['ship_id'])] = entry
        for key in resp:
            if key == 'expected':
                continue
            tmp[key] = resp[key]
        tmp['expected'] = expected
        res[region] = tmp
    return res


async def get_ship_dicts(wows_api: WowsAsync):
    res = {}
    for region in Region:
        resp = await wows_api.warships(region, fields='tier', language='en')
        data = resp['data']
        res[region.name] = {key: val['tier'] for key, val in data.items()}
    return res


def calc_wtr(expected, actual, coefficients, average_level) -> float:
    """
    Calculate WTR of a player based on the WTR formula on Warships today.
    :param expected: the server average
    :param actual: the actual value for the player
    :param coefficients: the coefficients
    :param average_level: the average level of the player's ships
    :return: the calculated value
    """

# Path: scripts/helpers.py
# def try_divide(numerator: Union[int, float], denominator: Union[int, float]):
#     """
#     Try to divide two numbers.
#     :param numerator: the numerator.
#     :param denominator: the denominator.
#     :return: the result of the division if denominator is not zero else 0.
#     """
#     return numerator / denominator if denominator else 0


# Path: world_of_warships/wtr.py
from aiohttp_wrapper import SessionManager
from wowspy import Region, WowsAsync
from scripts.helpers import try_divide

        expected = {}
        for entry in __expected:
            expected[str(entry['ship_id'])] = entry
        for key in resp:
            if key == 'expected':
                continue
            tmp[key] = resp[key]
        tmp['expected'] = expected
        res[region] = tmp
    return res


async def get_ship_dicts(wows_api: WowsAsync):
    res = {}
    for region in Region:
        resp = await wows_api.warships(region, fields='tier', language='en')
        data = resp['data']
        res[region.name] = {key: val['tier'] for key, val in data.items()}
    return res


def calc_wtr(expected, actual, coefficients, average_level) -> float:
    """
    Calculate WTR of a player based on the WTR formula on Warships today.
    :param expected: the server average
    :param actual: the actual value for the player
    :param coefficients: the coefficients
    :param average_level: the average level of the player's ships
    :return: the calculated value
    """

    wins = try_divide(actual['wins'], expected['wins'])