vcard2csv
vcard2csv copied to clipboard
Critical Failure when empty `tel.params` `dict` when calling `get_phone_numbers`
Issue
If an empty dict exists for tel.params in https://github.com/nbeaver/vcard2csv/blob/87649422a72e8d0c338f561efb931b779bb01f4a/vcard2csv.py#L34-L35
elif vCard.version.value == '3.0':
if 'CELL' in tel.params['TYPE']:
Traceback (most recent call last):
File "/Users/ben/src/vcard2csv/vcard2csv.py", line 163, in <module>
main()
File "/Users/ben/src/vcard2csv/vcard2csv.py", line 159, in main
vcard_info = get_info_list(vcard, vcard_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ben/src/vcard2csv/vcard2csv.py", line 63, in get_info_list
cell, home, work = get_phone_numbers(vCard)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ben/src/vcard2csv/vcard2csv.py", line 37, in get_phone_numbers
if 'CELL' in tel.params['TYPE']:
~~~~~~~~~~^^^^^^^^
KeyError: 'TYPE'
FIx
Add a check for empty dict
elif vCard.version.value == '3.0':
if not tel.params:
continue
if 'CELL' in tel.params['TYPE']: