Skip to content

Commit

Permalink
fix: prefix going as suffix, fix: phone number with +91 syntax gettin…
Browse files Browse the repository at this point in the history
…g discarded
  • Loading branch information
shivamgutgutia committed Dec 25, 2023
1 parent 48b649d commit dd4428e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .createDf import createDf
from .vcfGenerator import generateVcard,generateVcf
from .vcfGenerator import generateVcard,generateVcf
from .validateNumbers import validatePhoneNumber
14 changes: 7 additions & 7 deletions utils/validateNumbers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# import phonenumbers
import phonenumbers

# def validatePhoneNumber(number):
# try:
# parsedNumber = phonenumbers.parse(number)
# return phonenumbers.is_valid_number(parsedNumber)
# except phonenumbers.phonenumberutil.NumberParseException as e:
# return False
def validatePhoneNumber(number):
try:
parsedNumber = phonenumbers.parse(number)
return phonenumbers.is_valid_number(parsedNumber)
except phonenumbers.phonenumberutil.NumberParseException as e:
return False
4 changes: 2 additions & 2 deletions utils/vcfGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def generateVcard(row, headers, vCards):
family=row.get(headers.get("Last Name",""),""),
given=row.get(headers.get("First Name",""),""),
additional=row.get(headers.get("Middle Name",""),""),
suffix=request.form.get("Suffix","")+" "+str(row.name+1) if request.form.get("autoIncrement","") == "true" else request.form.get("Prefix",""),
suffix=request.form.get("Suffix","")+" "+str(row.name+1) if request.form.get("autoIncrement","") == "true" else request.form.get("Suffix",""),
prefix=request.form.get("Prefix","")
)

Expand All @@ -33,7 +33,7 @@ def generateVcard(row, headers, vCards):
fields = fields.split(",") if fields else []
for field in fields:
phone = row.get(field,"")
if phone and phone.isnumeric():
if phone:
telephone = vcard.add("tel")
telephone.type_param = ["HOME"]
telephone.value = phone
Expand Down

0 comments on commit dd4428e

Please sign in to comment.