Skip to content

Commit

Permalink
add:gender functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
shivamgutgutia committed Dec 24, 2023
1 parent bdb9772 commit 9399642
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions utils/vcfGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
def generateVcard(row, headers, vCards):
vcard = vobject.vCard()

#fn
fnParameters = [row.get(headers.get(string,""),"") for string in ["First Name","Middle Name","Last Name"]]
prefix = [request.form.get("Prefix")] if "Prefix" in request.form else []
suffix = [request.form.get("Suffix")] if "Suffix" in request.form else []
Expand All @@ -16,6 +17,8 @@ def generateVcard(row, headers, vCards):
else:
vcard.add("fn").value = "N/A"

#name

vcard.add("n").value = vobject.vcard.Name(
family=row.get(headers.get("Last Name",""),""),
given=row.get(headers.get("First Name",""),""),
Expand All @@ -24,6 +27,8 @@ def generateVcard(row, headers, vCards):
prefix=request.form.get("Prefix","")
)

#phone number

fields=headers.get("Phone Number","")
fields = fields.split(",") if fields else []
for field in fields:
Expand All @@ -33,6 +38,8 @@ def generateVcard(row, headers, vCards):
telephone.type_param = ["HOME"]
telephone.value = phone

#email

fields=headers.get("E-Mail","")
fields = fields.split(",") if fields else []
for field in fields:
Expand All @@ -41,6 +48,19 @@ def generateVcard(row, headers, vCards):
mail = vcard.add("email")
mail.type_param = ["HOME"]
mail.value = email

#gender

if str(row.get(headers.get("Gender",""),"")).lower().strip() in ["male","m"]:
vcard.add("gender").value = "M"
elif str(row.get(headers.get("Gender",""),"")).lower().strip() in ["female","f"]:
vcard.add("gender").value = "F"
elif str(row.get(headers.get("Gender",""),"")).lower().strip() in ["others","o"]:
vcard.add("gender").value = "O"
else:
vcard.add("gender").value = "U"

#version

vcard.add('version').value = '4.0'
vCards.append(vcard)
Expand Down

0 comments on commit 9399642

Please sign in to comment.