py-vobject / vobject

A full-featured Python package for parsing and creating iCalendar and vCard files
http://py-vobject.github.io/
28 stars 7 forks source link

Store X-* properties using Pythonic names #71

Open da4089 opened 1 month ago

da4089 commented 1 month ago

Import from: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=616592

python-vobject makes vCard/iCalendar properties available as object attributes. It knows that while e.g. X-SIP might hold a contact's SIP address and X-SIP is valid IANA syntax, the Python attributes must be named xsip, because the dash is not a valid character for a Python identifier. It does this by mapping '' to '-' in getattr/setattr, so the attribute name inside the instance (dict) actually contains a '-'.

There are tools in the Python universe that (rightfully) access e.g. dict directly (e.g. ipython's tab completion, among others). Those tools see the '-', which is not proper Python syntax.

I would think it were better if vobjects stored properties/attributes using Pythonic names and converted them from and to IANA rules on input and output respectively.