1

Using Codespeak's iCalendar python module to read and extract data from an iCalendar file, how would you pull out the various private Calendar extensions that are enclosed within vText?

The standard allows vendor-specific extensions, all starting with the X- prefix.

The ones I care about all have the following format:

X-VENDOR-CUSTOMFIELD;NAME="Custom Type";ID=21;TYPE=CustomAsset:AssetFormat Template
X-VENDOR-CUSTOMFIELD;NAME="Primary Contact";ID=22;TYPE=SingleLine: A Contact Name

I want to get the 'Name', ID and Type values for each occurrence of X-VENDOR-CUSTOMFIELD.

Looking up by the extension name will return a list of the right count:

custom_fields = event.get('X-VENDOR-CUSTOMFIELD');
print type(custom_fields) # yields list with 'vText' types

vText will give me back the escaped and encoded text value:

Asset Format Template
A Contact Name

This is just part of what I need. Is there a different way I should try to pick up the values of each extension?

I looked at this other SO post about Parsing files (ics/ icalendar) using Python for reference but it's not quite the same question as mine.

Related to this, is iCalendar better to use or should I consider vobject?

Community
  • 1
  • 1
Dan Holman
  • 825
  • 1
  • 10
  • 20

0 Answers0