开发者

Extracting calendar extensions with icalendar module in python

开发者 https://www.devze.com 2023-03-30 20:19 出处:网络
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?

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号