-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically get continent from country (#392)
- Loading branch information
Showing
10 changed files
with
289 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,262 @@ | ||
"""Continents module.""" | ||
|
||
|
||
def get_continent(country: str) -> str: | ||
"""Return the continent for the given country or ww.""" | ||
return _COUNTRIES_TO_CONTINENTS.get(country, "WW") | ||
|
||
|
||
# Co pied from https://github.com/mrbungle64/ecovacs-deebot.js/blob/master/countries.json on 11.01.2024 | ||
_COUNTRIES_TO_CONTINENTS = { | ||
"AD": "EU", | ||
"AE": "AS", | ||
"AF": "AS", | ||
"AG": "NA", | ||
"AI": "NA", | ||
"AL": "EU", | ||
"AM": "AS", | ||
"AO": "WW", | ||
"AQ": "WW", | ||
"AR": "WW", | ||
"AS": "WW", | ||
"AT": "EU", | ||
"AU": "WW", | ||
"AW": "NA", | ||
"AX": "EU", | ||
"AZ": "AS", | ||
"BA": "EU", | ||
"BB": "NA", | ||
"BD": "AS", | ||
"BE": "EU", | ||
"BF": "WW", | ||
"BG": "EU", | ||
"BH": "AS", | ||
"BI": "WW", | ||
"BJ": "WW", | ||
"BL": "NA", | ||
"BM": "NA", | ||
"BN": "AS", | ||
"BO": "WW", | ||
"BQ": "NA", | ||
"BR": "WW", | ||
"BS": "NA", | ||
"BT": "AS", | ||
"BV": "WW", | ||
"BW": "WW", | ||
"BY": "EU", | ||
"BZ": "NA", | ||
"CA": "NA", | ||
"CC": "AS", | ||
"CD": "WW", | ||
"CF": "WW", | ||
"CG": "WW", | ||
"CH": "EU", | ||
"CI": "WW", | ||
"CK": "WW", | ||
"CL": "WW", | ||
"CM": "WW", | ||
"CN": "WW", | ||
"CO": "WW", | ||
"CR": "NA", | ||
"CU": "NA", | ||
"CV": "WW", | ||
"CW": "NA", | ||
"CX": "AS", | ||
"CY": "EU", | ||
"CZ": "EU", | ||
"DE": "EU", | ||
"DJ": "WW", | ||
"DK": "EU", | ||
"DM": "NA", | ||
"DO": "NA", | ||
"DZ": "WW", | ||
"EC": "WW", | ||
"EE": "EU", | ||
"EG": "WW", | ||
"EH": "WW", | ||
"ER": "WW", | ||
"ES": "EU", | ||
"ET": "WW", | ||
"FI": "EU", | ||
"FJ": "WW", | ||
"FK": "WW", | ||
"FM": "WW", | ||
"FO": "EU", | ||
"FR": "EU", | ||
"GA": "WW", | ||
"GB": "EU", | ||
"GD": "NA", | ||
"GE": "AS", | ||
"GF": "WW", | ||
"GG": "EU", | ||
"GH": "WW", | ||
"GI": "EU", | ||
"GL": "NA", | ||
"GM": "WW", | ||
"GN": "WW", | ||
"GP": "NA", | ||
"GQ": "WW", | ||
"GR": "EU", | ||
"GS": "WW", | ||
"GT": "NA", | ||
"GU": "WW", | ||
"GW": "WW", | ||
"GY": "WW", | ||
"HK": "AS", | ||
"HM": "WW", | ||
"HN": "NA", | ||
"HR": "EU", | ||
"HT": "NA", | ||
"HU": "EU", | ||
"ID": "AS", | ||
"IE": "EU", | ||
"IL": "AS", | ||
"IM": "EU", | ||
"IN": "AS", | ||
"IO": "AS", | ||
"IQ": "AS", | ||
"IR": "AS", | ||
"IS": "EU", | ||
"IT": "EU", | ||
"JE": "EU", | ||
"JM": "NA", | ||
"JO": "AS", | ||
"JP": "AS", | ||
"KE": "WW", | ||
"KG": "AS", | ||
"KH": "AS", | ||
"KI": "WW", | ||
"KM": "WW", | ||
"KN": "NA", | ||
"KP": "AS", | ||
"KR": "AS", | ||
"KW": "AS", | ||
"KY": "NA", | ||
"KZ": "AS", | ||
"LA": "AS", | ||
"LB": "AS", | ||
"LC": "NA", | ||
"LI": "EU", | ||
"LK": "AS", | ||
"LR": "WW", | ||
"LS": "WW", | ||
"LT": "EU", | ||
"LU": "EU", | ||
"LV": "EU", | ||
"LY": "WW", | ||
"MA": "WW", | ||
"MC": "EU", | ||
"MD": "EU", | ||
"ME": "EU", | ||
"MF": "NA", | ||
"MG": "WW", | ||
"MH": "WW", | ||
"MK": "EU", | ||
"ML": "WW", | ||
"MM": "AS", | ||
"MN": "AS", | ||
"MO": "AS", | ||
"MP": "WW", | ||
"MQ": "NA", | ||
"MR": "WW", | ||
"MS": "NA", | ||
"MT": "EU", | ||
"MU": "WW", | ||
"MV": "AS", | ||
"MW": "WW", | ||
"MX": "NA", | ||
"MY": "AS", | ||
"MZ": "WW", | ||
"NA": "WW", | ||
"NC": "WW", | ||
"NE": "WW", | ||
"NF": "WW", | ||
"NG": "WW", | ||
"NI": "NA", | ||
"NL": "EU", | ||
"NO": "EU", | ||
"NP": "AS", | ||
"NR": "WW", | ||
"NU": "WW", | ||
"NZ": "WW", | ||
"OM": "AS", | ||
"PA": "NA", | ||
"PE": "WW", | ||
"PF": "WW", | ||
"PG": "WW", | ||
"PH": "AS", | ||
"PK": "AS", | ||
"PL": "EU", | ||
"PM": "NA", | ||
"PN": "WW", | ||
"PR": "NA", | ||
"PS": "AS", | ||
"PT": "EU", | ||
"PW": "WW", | ||
"PY": "WW", | ||
"QA": "AS", | ||
"RE": "WW", | ||
"RO": "EU", | ||
"RS": "EU", | ||
"RU": "EU", | ||
"RW": "WW", | ||
"SA": "AS", | ||
"SB": "WW", | ||
"SC": "WW", | ||
"SD": "WW", | ||
"SE": "EU", | ||
"SG": "AS", | ||
"SH": "WW", | ||
"SI": "EU", | ||
"SJ": "EU", | ||
"SK": "EU", | ||
"SL": "WW", | ||
"SM": "EU", | ||
"SN": "WW", | ||
"SO": "WW", | ||
"SR": "WW", | ||
"SS": "WW", | ||
"ST": "WW", | ||
"SV": "NA", | ||
"SX": "NA", | ||
"SY": "AS", | ||
"SZ": "WW", | ||
"TC": "NA", | ||
"TD": "WW", | ||
"TF": "WW", | ||
"TG": "WW", | ||
"TH": "AS", | ||
"TJ": "AS", | ||
"TK": "WW", | ||
"TL": "WW", | ||
"TM": "AS", | ||
"TN": "WW", | ||
"TO": "WW", | ||
"TR": "AS", | ||
"TT": "NA", | ||
"TV": "WW", | ||
"TW": "AS", | ||
"TZ": "WW", | ||
"UA": "EU", | ||
"UG": "WW", | ||
"UK": "EU", | ||
"UM": "WW", | ||
"US": "NA", | ||
"UY": "WW", | ||
"UZ": "AS", | ||
"VA": "EU", | ||
"VC": "NA", | ||
"VE": "WW", | ||
"VG": "NA", | ||
"VI": "NA", | ||
"VN": "AS", | ||
"VU": "WW", | ||
"WF": "WW", | ||
"WS": "WW", | ||
"XK": "EU", | ||
"YE": "AS", | ||
"YT": "WW", | ||
"ZA": "WW", | ||
"ZM": "WW", | ||
"ZW": "WW", | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import pytest | ||
|
||
from deebot_client.util.continents import get_continent | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("continent", "expected"), | ||
[ | ||
("IT", "EU"), | ||
("DE", "EU"), | ||
("US", "NA"), | ||
("invalid", "WW"), | ||
("", "WW"), | ||
("XX", "WW"), | ||
], | ||
) | ||
def test_get_continent(continent: str, expected: str) -> None: | ||
assert get_continent(continent) == expected |
File renamed without changes.