Skip to content

Commit ac585e7

Browse files
committed
from iPad
1 parent 7bebcfc commit ac585e7

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

_2018/Addcontact.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# https://gist.github.com/my4paws/ae7dc32ba9937996d4d13848ab13404c
2+
3+
# https://forum.omz-software.com/topic/4821/add-contact-to-a-group
4+
5+
import contacts
6+
import clipboard
7+
import webbrowser
8+
import dateutil
9+
name = clipboard.get().split(',')
10+
pers = contacts.Person()
11+
grp = contacts.Group()
12+
pers.first_name = name[0]
13+
pers.last_name = name[1]
14+
pers.middle_name = name[2]
15+
pers.prefix = name[3]
16+
pers.job_title = name[4]
17+
pers.department = name[5]
18+
pers.email = [(contacts.HOME, name[6])]
19+
pers.address = [(contacts.HOME,
20+
{contacts.STREET: name[7],
21+
contacts.CITY: name[8],
22+
contacts.STATE: name[9],
23+
contacts.ZIP: name[10],
24+
contacts.COUNTRY: name[11]})]
25+
pers.nickname = name[13]
26+
pers.organization = name[14]
27+
pers.phone = [(contacts.HOME, name[15]),(contacts.IPHONE, name[16]),(contacts.WORK, name[17])]
28+
from dateutil import parser
29+
string_date = parser.parse(name[18])
30+
pers.birthday = string_date
31+
pers.url = [(contacts.HOMEPAGE, name[19])]
32+
33+
#here name[20] would provide the name of the group I want the contact to be added to
34+
35+
contacts.add_person(pers)
36+
contacts.save()
37+
webbrowser.open('workflow://')

0 commit comments

Comments
 (0)