diff --git a/utils/vcfGenerator.py b/utils/vcfGenerator.py index 1025e18..6df1668 100644 --- a/utils/vcfGenerator.py +++ b/utils/vcfGenerator.py @@ -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 [] @@ -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",""),""), @@ -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: @@ -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: @@ -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)