-
Notifications
You must be signed in to change notification settings - Fork 0
/
makecontacts.py
48 lines (36 loc) · 913 Bytes
/
makecontacts.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
import vobject
ORGANIZATION = "ORG"
newcontactfile = ""
mainloop = True
while mainloop:
contact = vobject.vCard()
contact.add("n")
contact.add("fn")
contact.add("org")
contact.add("tel")
name = str(input("Name: "))
if name == "quit":
mainloop = False
continue
if " " not in name:
name += f" ({ORGANIZATION})"
numberFlag = True
while numberFlag:
number = str(input("Number: "))
if len(number) != 13 and number != "quit":
print("Length of number is not correct. AGAIN!!!")
continue
else:
numberFlag = False
if number == "quit":
mainloop = False
continue
# family is last name (I think)
contact.n.value = vobject.vcard.Name(family = "", given = name)
contact.fn.value = name
contact.tel.value = number
contact.org.value = [ORGANIZATION]
newcontactfile += contact.serialize()
print(newcontactfile)
with open("newcontacts.vcf", "w") as d:
d.write(newcontactfile)