Skip to content

Simple way to import vcf card into an addressbook #346

Description

@agx

Maybe I'm missing something obvious but I didn't find a way to import a vcf file (as is e.g. ever so often attached to an email) into an addressbook. E.g. khal has khal import <icsfile> to import calendar entries. Would be nice to have something similar for khard.

I tried

khard new -i foo.vcf

but that raises an exception:

$ khard new -i friscobrisco.vcf 
Wrapping unversioned vCard object, setting version to 3.0.
Traceback (most recent call last):
  File "/usr/bin/khard", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/usr/lib/python3/dist-packages/khard/khard.py", line 1182, in main
    new_subcommand(args.addressbook, input_from_stdin_or_file,
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                   args.open_editor)
                   ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/khard/khard.py", line 390, in new_subcommand
    new_contact = CarddavObject.from_yaml(
        abook, data, config.private_objects,
        config.preferred_vcard_version, config.localize_dates)
  File "/usr/lib/python3/dist-packages/khard/carddav_object.py", line 1389, in from_yaml
    contact.update(yaml)
    ~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3/dist-packages/khard/carddav_object.py", line 1060, in update
    contact_data = self._parse_yaml(input)
  File "/usr/lib/python3/dist-packages/khard/carddav_object.py", line 996, in _parse_yaml
    if not (contact_data.get("First name") or contact_data.get("Last name")
            ^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'get'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions