pathetic encoding cleaning
This commit is contained in:
parent
0aa8b0a234
commit
988f662265
1 changed files with 19 additions and 2 deletions
|
|
@ -40,10 +40,27 @@ for line in input_file:
|
||||||
number = number.replace("-", "")
|
number = number.replace("-", "")
|
||||||
number = phonenumbers.parse(number, region="FR")
|
number = phonenumbers.parse(number, region="FR")
|
||||||
number = phonenumbers.format_number(number, phonenumbers.PhoneNumberFormat.INTERNATIONAL)
|
number = phonenumbers.format_number(number, phonenumbers.PhoneNumberFormat.INTERNATIONAL)
|
||||||
clean_tel.append({"value": number, "type": []})
|
if number not in clean_tel:
|
||||||
|
clean_tel.append(number)
|
||||||
except phonenumbers.phonenumberutil.NumberParseException:
|
except phonenumbers.phonenumberutil.NumberParseException:
|
||||||
continue
|
continue
|
||||||
contact.tel = clean_tel
|
|
||||||
|
contact.tel = [{"value": x, "type": []} for x in clean_tel]
|
||||||
|
|
||||||
|
contact.fn = quopri.decodestring(contact.fn).decode()
|
||||||
|
|
||||||
|
clean_n = []
|
||||||
|
for name in contact.n:
|
||||||
|
clean = quopri.decodestring(name).decode()
|
||||||
|
clean_n.append(clean)
|
||||||
|
contact.name = clean_n
|
||||||
|
print(contact.name)
|
||||||
|
|
||||||
|
clean_nickname = []
|
||||||
|
for nick in contact.nickname:
|
||||||
|
nick = quopri.decodestring(nick).decode()
|
||||||
|
clean_n.append(nick)
|
||||||
|
contact.nickname = clean_nickname
|
||||||
|
|
||||||
vcf_text = contact.to_vcard()
|
vcf_text = contact.to_vcard()
|
||||||
output.write(vcf_text)
|
output.write(vcf_text)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue