-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper_country.py
59 lines (55 loc) · 1.4 KB
/
helper_country.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class HelperCountry:
# Countries
LITHUANIA = "Lithuania"
LATVIA = "Latvia"
POLAND = "Poland"
RUSSIA = "Russia"
TURKEY = "Turkey"
USA = "USA"
MEXICO = "Mexico"
# Regions
NORTH_AMERICA = "North America"
EUROPE = "Europe"
ASIA = "Asia"
# Country Object dict
_COUNTRY_DATA = {
LITHUANIA: {
"vat": 21,
"region": EUROPE
},
LATVIA: {
"vat": 18,
"region": EUROPE
},
POLAND: {
"vat": 42,
"region": EUROPE
},
RUSSIA: {
"vat": 69,
"region": ASIA
},
TURKEY: {
"vat": 2,
"region": ASIA
},
USA: {
"vat": 5,
"region": NORTH_AMERICA
},
MEXICO: {
"vat": 17,
"region": NORTH_AMERICA
},
}
@staticmethod
def get_country_data(country):
if not isinstance(country, str):
raise TypeError("'get_country' method expected a string")
country_data = HelperCountry._COUNTRY_DATA.get(country)
if not country_data:
raise ValueError(f"Country not found, available countries are: {', '.join(HelperCountry._COUNTRY_DATA.keys())}")
return country_data
@staticmethod
def is_country_valid(country):
return country in HelperCountry._COUNTRY_DATA.keys()