Skip to main content

Python icalendar (rfc5545) parser

Project description

Ics.py : iCalendar for Humans

https://travis-ci.org/C4ptainCrunch/ics.py.png?branch=master https://coveralls.io/repos/C4ptainCrunch/ics.py/badge.png License Awesomeness

(Release 0.1.1)

Documentation : http://icspy.readthedocs.org/

Ics.py is a pythonic and easy iCalendar (rfc5545) library. It’s goals are to read and write ics data in a developper-friendly way.

It is written in Python (>=2.7 and >=3.3) and is Apache2 Licensed.

iCalendar is complicated, you don’t like RFCs but you want/have to use the ics format and you love pythonic APIs? ics.py is for you!

Quickstart

$ pip install ics

Import a calendar from a file

>>> from ics import Calendar
>>> from urllib2 import urlopen # import requests
>>> url = "http://hackeragenda.urlab.be/events/events.ics"
>>> c = Calendar(urlopen(url).read().decode('iso-8859-1'))
>>> # could also use 'requests' here
>>> # c = Calendar(requests.get(url).text)
>>> c
<Calendar with 42 events>

>>> c.events
[<Event 'SmartMonday #1' begin:2013-12-13 20:00:00 end:2013-12-13 23:00:00>,
<Event 'RFID workshop' begin:2013-12-06 12:00:00 end:2013-12-06 19:00:00>,
...]

>>> e = c.events[10]

>>> "Event '{}' started {}".format(e.name, e.begin.humanize())
"Event 'Mitch Altman soldering workshop' started 6 days ago"

Create a new calendar and add events

>>> from ics import Calendar, Event
>>> c = Calendar()
>>> e = Event()
>>> e.name = "My cool event"
>>> e.begin = '20140101 00:00:00'
>>> c.events.append(e)

>>> c.events
[<Event 'My cool event' begin:2014-01-01 00:00:00 end:2014-01-01 00:00:01>]

Export a Calendar to a file

>>> with open('my.ics', 'w') as f:
>>>     f.writelines(c)
>>> # And it's done !

iCalendar-formatted data is also available in a string

>>> str(c)
'BEGIN:VCALENDAR\nPRODID:...

License

ics.py is under the Apache 2 software license because… bah! Why not?

Copyright 2013 Nikita Marchant

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

ics.py uses heavily arrow (Apache license) and python-dateutil (GPL licensed).

ics.py includes also something like 10 lines of arrow’s code (in utils.iso_precision) which are ©Chris Smith. Thanks to him!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ics-0.1.3.tar.gz (10.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page