import pickle


def unit(name, attribute='gcost'):
    """
    Returns Unit resource cost by Unit Name.
    :param name: Unit Name
    :param attribute: Attribute Value (gcost (default), rcost)
    :return: Decoded attribute
    """

    file = open('./battlefortune/data/units', 'rb')
    output = pickle.load(file)[name][attribute]
    return output