forked from OSAlt/legacy-secret-santa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
person.py
27 lines (23 loc) · 1022 Bytes
/
person.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
from incf.countryutils import transformations
class Person:
def __init__(self, name, email, invalid_matches, amazon, country):
self.name = name
self.email = email
self.invalid_matches = invalid_matches
self.amazon = amazon
try:
self.continent = transformations.cn_to_ctn(country)
except KeyError as e:
self.continent = transformations.cn_to_ctn(self.__handle_country_name(country))
# Some names in ISO 3166 are almost impossible to get right. So lets help
# our users out a little bit by matching some common ones.
def __handle_country_name(self, country):
for long_name in ["United States of America",
"United Kingdom of Great Britain & Northern Ireland"]:
if long_name.find(country) != -1:
return long_name
raise KeyError(country)
def amazon_url(self):
return self.amazon
def __str__(self):
return "%s <%s>" % (self.name, self.email)