""" Constants used in this repo """
import os
from datetime import timedelta
from urllib.parse import urljoin

BASE_URL = "https://pvoutput.org"
MAP_URL = urljoin(BASE_URL, "map.jsp")
REGIONS_URL = urljoin(BASE_URL, "region.jsp")

# Country codes used by PVOutput.org on, for example,
# https://pvoutput.org/map.jsp.  Taken from
# https://pvoutput.org/help.html#api-addsystem.

PV_OUTPUT_COUNTRY_CODES = {
    "New South Wales": 1,
    "Afghanistan": 2,
    "Akrotiri": 3,
    "Albania": 4,
    "Algeria": 5,
    "American Samoa": 6,
    "Andorra": 7,
    "Angola": 8,
    "Anguilla": 9,
    "Antarctica": 10,
    "Antigua and Barbuda": 11,
    "Arctic Ocean": 12,
    "Argentina": 13,
    "Armenia": 14,
    "Aruba": 15,
    "Ashmore and Cartier Islands": 16,
    "Atlantic Ocean": 17,
    "Austria": 18,
    "Azerbaijan": 19,
    "Bahamas, The": 20,
    "Bahrain": 21,
    "Bangladesh": 22,
    "Barbados": 23,
    "Belarus": 24,
    "Belgium": 25,
    "Belize": 26,
    "Benin": 27,
    "Bermuda": 28,
    "Bhutan": 29,
    "Bolivia": 30,
    "Bosnia and Herzegovina": 31,
    "Botswana": 32,
    "Bouvet Island": 33,
    "Brazil": 34,
    "British Indian Ocean Territory": 35,
    "British Virgin Islands": 36,
    "Brunei": 37,
    "Bulgaria": 38,
    "Burkina Faso": 39,
    "Burma": 40,
    "Burundi": 41,
    "Cambodia": 42,
    "Cameroon": 43,
    "Canada": 44,
    "Cape Verde": 45,
    "Cayman Islands": 46,
    "Central African Republic": 47,
    "Chad": 48,
    "Chile": 49,
    "China": 50,
    "Christmas Island": 51,
    "Clipperton Island": 52,
    "Cocos (Keeling) Islands": 53,
    "Colombia": 54,
    "Comoros": 55,
    "Congo, Democratic Republic of the": 56,
    "Congo, Republic of the": 57,
    "Cook Islands": 58,
    "Coral Sea Islands": 59,
    "Costa Rica": 60,
    "Cote d'Ivoire": 61,
    "Croatia": 62,
    "Cuba": 63,
    "Curacao": 64,
    "Cyprus": 65,
    "Czech Republic": 66,
    "Denmark": 67,
    "Dhekelia": 68,
    "Djibouti": 69,
    "Dominica": 70,
    "Dominican Republic": 71,
    "Ecuador": 72,
    "Egypt": 73,
    "El Salvador": 74,
    "Equatorial Guinea": 75,
    "Eritrea": 76,
    "Estonia": 77,
    "Ethiopia": 78,
    "Falkland Islands": 79,
    "Faroe Islands": 80,
    "Fiji": 81,
    "Finland": 82,
    "France": 83,
    "French Polynesia": 84,
    "French Southern and Antarctic Lands": 85,
    "Gabon": 86,
    "Gambia, The": 87,
    "Gaza Strip": 88,
    "Georgia": 89,
    "Germany": 90,
    "Ghana": 91,
    "Gibraltar": 92,
    "Greece": 93,
    "Greenland": 94,
    "Grenada": 95,
    "Guam": 96,
    "Guatemala": 97,
    "Guernsey": 98,
    "Guinea": 99,
    "Guinea-Bissau": 100,
    "Guyana": 101,
    "Haiti": 102,
    "Heard Island and McDonald Islands": 103,
    "Holy See (Vatican City)": 104,
    "Honduras": 105,
    "Hong Kong": 106,
    "Hungary": 107,
    "Iceland": 108,
    "India": 109,
    "Indian Ocean": 110,
    "Indonesia": 111,
    "Iran": 112,
    "Iraq": 113,
    "Ireland": 114,
    "Isle of Man": 115,
    "Israel": 116,
    "Italy": 117,
    "Jamaica": 118,
    "Jan Mayen": 119,
    "Japan": 120,
    "Jersey": 121,
    "Jordan": 122,
    "Kazakhstan": 123,
    "Kenya": 124,
    "Kiribati": 125,
    "Korea, North": 126,
    "Korea, South": 127,
    "Kosovo": 128,
    "Kuwait": 129,
    "Kyrgyzstan": 130,
    "Laos": 131,
    "Latvia": 132,
    "Lebanon": 133,
    "Lesotho": 134,
    "Liberia": 135,
    "Libya": 136,
    "Liechtenstein": 137,
    "Lithuania": 138,
    "Luxembourg": 139,
    "Macau": 140,
    "Macedonia": 141,
    "Madagascar": 142,
    "Malawi": 143,
    "Malaysia": 144,
    "Maldives": 145,
    "Mali": 146,
    "Malta": 147,
    "Marshall Islands": 148,
    "Mauritania": 149,
    "Mauritius": 150,
    "Mayotte": 151,
    "Mexico": 152,
    "Micronesia": 153,
    "Moldova": 154,
    "Monaco": 155,
    "Mongolia": 156,
    "Montenegro": 157,
    "Montserrat": 158,
    "Morocco": 159,
    "Mozambique": 160,
    "Namibia": 161,
    "Nauru": 162,
    "Navassa Island": 163,
    "Nepal": 164,
    "Netherlands": 165,
    "New Caledonia": 166,
    "New Zealand": 167,
    "Nicaragua": 168,
    "Niger": 169,
    "Nigeria": 170,
    "Niue": 171,
    "Norfolk Island": 172,
    "Northern Mariana Islands": 173,
    "Norway": 174,
    "Oman": 175,
    "Pakistan": 176,
    "Palau": 177,
    "Panama": 178,
    "Papua New Guinea": 179,
    "Paracel Islands": 180,
    "Paraguay": 181,
    "Peru": 182,
    "Philippines": 183,
    "Pitcairn Islands": 184,
    "Poland": 185,
    "Portugal": 186,
    "Puerto Rico": 187,
    "Qatar": 188,
    "Romania": 189,
    "Russia": 190,
    "Rwanda": 191,
    "Saint Barthelemy": 192,
    "Saint Helena, Ascension, and Tristan da Cunha": 193,
    "Saint Kitts and Nevis": 194,
    "Saint Lucia": 195,
    "Saint Martin": 196,
    "Saint Pierre and Miquelon": 197,
    "Saint Vincent and the Grenadines": 198,
    "Samoa": 199,
    "San Marino": 200,
    "Sao Tome and Principe": 201,
    "Saudi Arabia": 202,
    "Senegal": 203,
    "Serbia": 204,
    "Seychelles": 205,
    "Sierra Leone": 206,
    "Singapore": 207,
    "Sint Maarten": 208,
    "Slovakia": 209,
    "Slovenia": 210,
    "Solomon Islands": 211,
    "Somalia": 212,
    "South Africa": 213,
    "South Georgia and South Sandwich Is.": 214,
    "Southern Ocean": 215,
    "Spain": 216,
    "Spratly Islands": 217,
    "Sri Lanka": 218,
    "Sudan": 219,
    "Suriname": 220,
    "Svalbard": 221,
    "Swaziland": 222,
    "Sweden": 223,
    "Switzerland": 224,
    "Syria": 225,
    "Taiwan": 226,
    "Tajikistan": 227,
    "Tanzania": 228,
    "Thailand": 229,
    "Timor-Leste": 230,
    "Togo": 231,
    "Tokelau": 232,
    "Tonga": 233,
    "Trinidad and Tobago": 234,
    "Tunisia": 235,
    "Turkey": 236,
    "Turkmenistan": 237,
    "Turks and Caicos Islands": 238,
    "Tuvalu": 239,
    "Uganda": 240,
    "Ukraine": 241,
    "United Arab Emirates": 242,
    "United Kingdom": 243,
    "United States": 244,
    "Uruguay": 245,
    "Uzbekistan": 246,
    "Vanuatu": 247,
    "Venezuela": 248,
    "Vietnam": 249,
    "Virgin Islands": 250,
    "Wake Island": 251,
    "Wallis and Futuna": 252,
    "West Bank": 253,
    "Western Sahara": 254,
    "Yemen": 255,
    "Zambia": 256,
    "Zimbabwe": 257,
}

PV_OUTPUT_MAP_COLUMN_NAMES = {
    "timeseries_duration": "c",
    "average_generation_per_day": "avg",
    "efficiency": "gss",
    "power_generation": "atg",
    "capacity": "ss",
    "address": "o",
    "name": "sn",
}


ONE_DAY = timedelta(days=1)

PV_OUTPUT_DATE_FORMAT = "%Y%m%d"
CONFIG_FILENAME = os.environ.get("PVOUTPUT_CONFIG", os.path.expanduser("~/.pvoutput.yml"))
RATE_LIMIT_PARAMS_TO_API_HEADERS = {
    "rate_limit_remaining": "X-Rate-Limit-Remaining",
    "rate_limit_total": "X-Rate-Limit-Limit",
    "rate_limit_reset_time": "X-Rate-Limit-Reset",
}
