-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerson.py
50 lines (40 loc) · 1.06 KB
/
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from Log import Log
class Person:
ATTR_NOT_AVAILABLE = "undefined"
# BEGIN PREFDEFINE ATTRIBUTES
NAME = "name"
NAME_FIRST = "name_first"
NAME_DISPLAY = "name_display"
BIRTHDAY = "birthday"
STREET = "street"
POSTCODE = "postcode"
CITY = "city"
COUNTRY = "country"
TELEPHONE = "telephone"
MOBILEPHONE = "mobilephone"
EMAIL_PRIVATE = "email_private"
EMAIL = "email"
COMPANY = "company"
# END PREFDEFINE ATTRIBUTES
def __init__(self):
self._attributes = {}
def __str__(self):
return self.getAttribute(Person.NAME) + ", " + self.getAttribute(Person.NAME_FIRST)
def __repr__(self):
return str(self.toString())
def getAttribute(self, key):
try:
attr = self._attributes[key]
if(attr == "" or attr == None):
attr = Person,ATTR_NOT_AVAILABLE
return attr
except:
Log.debug(self.__class__, "key does not exist =" + key)
return Person.ATTR_NOT_AVAILABLE
def setAttribute(self, key, value):
self._attributes[key] = value
def toString(self):
s = ""
for k, v in self._attributes.items():
s = s + k + ": " + v + ", "
return s