Compare commits
No commits in common. "988f66226586b0cb418a0e8e4bf1338e0400a938" and "01ebe8b545fadf47a5894baf6d68121c3d7f0aef" have entirely different histories.
988f662265
...
01ebe8b545
1 changed files with 12 additions and 25 deletions
|
|
@ -1,18 +1,18 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import quopri
|
|
||||||
import base64
|
import base64
|
||||||
import pickle
|
import pickle
|
||||||
import phonenumbers
|
import phonenumbers
|
||||||
from pythonvCard4.vcard import Contact
|
from pythonvCard4.vcard import Contact
|
||||||
|
|
||||||
input_file = open(sys.argv[1], 'r', encoding="latin-1").readlines()
|
input_file = open(sys.argv[1], 'r').readlines()
|
||||||
output = open('output.vcf', 'w')
|
|
||||||
|
|
||||||
check_for_multiple_pictures = False
|
check_for_multiple_pictures = False
|
||||||
|
|
||||||
|
cards = []
|
||||||
current_card = ""
|
current_card = ""
|
||||||
|
|
||||||
for line in input_file:
|
for line in input_file:
|
||||||
|
|
||||||
current_card += line
|
current_card += line
|
||||||
|
|
||||||
if "END:VCARD" in line:
|
if "END:VCARD" in line:
|
||||||
|
|
@ -40,29 +40,16 @@ 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)
|
||||||
if number not in clean_tel:
|
clean_tel.append({"value": number, "type": []})
|
||||||
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]
|
cards.append(contact)
|
||||||
|
|
||||||
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()
|
|
||||||
output.write(vcf_text)
|
|
||||||
current_card = ""
|
current_card = ""
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
output = open('output.vcf', 'w')
|
||||||
|
for card in cards:
|
||||||
|
vcf_text = card.to_vcard()
|
||||||
|
output.write(vcf_text)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue