用于访问CalDAV服务器的Python库 [英] Python library to access a CalDAV server

查看:397
本文介绍了用于访问CalDAV服务器的Python库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站空间上运行ownCloud以获得共享日历。现在,我正在寻找合适的python库来获取对日历的只读访问权限。我想在Intranet网站上放一些日历信息。

I run ownCloud on my webspace for a shared calendar. Now I'm looking for a suitable python library to get read only access to the calendar. I want to put some information of the calendar on an intranet website.

我已经尝试过 http://trac.calendarserver.org/wiki/CalDAVClientLibrary ,但它总是通过查询命令返回 NotImplementedError ,因此我的猜测是查询命令不适​​用于给定的库。

I have tried http://trac.calendarserver.org/wiki/CalDAVClientLibrary but it always returns a NotImplementedError with the query command, so my guess is that the query command doesn't work well with the given library.

我可以改用什么库?

推荐答案

我推荐该库 caldav

该库的只读功能非常好,对我来说直截了当。它将完成获取日历和阅读事件的全部工作,并以 iCalendar格式返回它们。有关 caldav 库的更多信息,也可以在文档

Read-only is working really well with this library and looks straight-forward to me. It will do the whole job of getting calendars and reading events, returning them in the iCalendar format. More information about the caldav library can also be obtained in the documentation.

import caldav

client = caldav.DAVClient(<caldav-url>, username=<username>,
                          password=<password>)
principal = client.principal()
for calendar in principal.calendars():
    for event in calendar.events():
        ical_text = event.data

关于此可以使用 icalendar 库读取特定字段,例如类型(例如事件,待办事项,警报),名称,时间等-一个好的起点可能是此问题

From this on you can use the icalendar library to read specific fields such as the type (e. g. event, todo, alarm), name, times, etc. - a good starting point may be this question.

这篇关于用于访问CalDAV服务器的Python库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆