在python中使用icalendar模块提取日历扩展

时间:2011-08-24 00:44:53

标签: python icalendar

使用Codespeak的iCalendar python模块从iCalendar文件中读取和提取数据,您将如何提取vText中包含的各种私有日历扩展?

该标准允许特定于供应商的扩展,所有扩展都以X-前缀开头。

我关心的所有人都有以下格式:

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

我想获取每次出现X-VENDOR-CUSTOMFIELD的'名称',ID和类型值。

通过扩展名名查找将返回正确计数列表:

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

vText将返回转义和编码的文本值:

Asset Format Template
A Contact Name

这只是我需要的一部分。是否有不同的方法我应该尝试获取每个扩展的值?

我查看了关于Parsing files (ics/ icalendar) using Python的其他SO帖子以供参考,但这与我的问题不完全相同。

与此相关,iCalendar更好用或者我应该考虑vobject吗?

0 个答案:

没有答案