Skip to main content

iCalendar parser/generator

Project description

The iCalendar package is a parser/generator of iCalendar files for use with Python. It follows the RFC 2445 (iCalendar) specification.

Introduction

I (Max M) have often needed to parse and generate iCalendar files. Finally I got tired of writing ad-hoc tools.

So this is my attempt at making an iCalendar package for Python. The inspiration has come from the email package in the standard lib, which I think is pretty simple, yet efficient and powerful.

The package can both generate and parse iCalendar files, and can easily be used as is.

The aim is to make a package that is fully compliant to RFC 2445, well designed, simple to use and well documented.

News

Example

To open and parse a file:

>>> from icalendar import Calendar, Event
>>> cal = Calendar.from_string(open('test.ics','rb').read())
>>> cal
VCALENDAR({'VERSION': vText(u'2.0'), 'METHOD': vText(u'Request'), 'PRODID': vText(u'-//My product//mxm.dk/')})

>>> for component in cal.walk():
...     component.name
'VCALENDAR'
'VEVENT'
'VEVENT'

To create a calendar and write it to disk:

>>> cal = Calendar()
>>> from datetime import datetime
>>> from icalendar import UTC # timezone
>>> cal.add('prodid', '-//My calendar product//mxm.dk//')
>>> cal.add('version', '2.0')

>>> event = Event()
>>> event.add('summary', 'Python meeting about calendaring')
>>> event.add('dtstart', datetime(2005,4,4,8,0,0,tzinfo=UTC))
>>> event.add('dtend', datetime(2005,4,4,10,0,0,tzinfo=UTC))
>>> event.add('dtstamp', datetime(2005,4,4,0,10,0,tzinfo=UTC))
>>> event['uid'] = '20050115T101010/27346262376@mxm.dk'
>>> event.add('priority', 5)

>>> cal.add_component(event)

>>> f = open('example.ics', 'wb')
>>> f.write(cal.as_string())
>>> f.close()

More documentation

Consult this example for introductory doctests and explanations. Here are two smaller examples.

All modules and classes also have doctests that shows how they work. There is also an interfaces.py file which describes the API.

Mailing list

If you have any comments or feedback on the module, please use the iCalendar mailing list. You can subscribe to it here:

http://codespeak.net/mailman/listinfo/icalendar-dev

We would love to hear use cases, or get ideas for improvements.

There is also a checkins mailing list, if you want to follow development:

http://codespeak.net/mailman/listinfo/icalendar-checkins

Download

You can also check out the development version of iCalendar from subversion, using a command like:

svn co http://codespeak.net/svn/iCalendar/trunk iCalendar

Dependencies

It is dependent on the datetime package, so it requires Python >= 2.3. There are no other dependencies.

License

LGPL. See LICENSE.txt for details.

Project details


Release history Release notifications | RSS feed

This version

2.1

Download files

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

Source Distribution

djangoplicity-icalendar-2.1.tar.gz (33.8 kB view details)

Uploaded Source

File details

Details for the file djangoplicity-icalendar-2.1.tar.gz.

File metadata

  • Download URL: djangoplicity-icalendar-2.1.tar.gz
  • Upload date:
  • Size: 33.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for djangoplicity-icalendar-2.1.tar.gz
Algorithm Hash digest
SHA256 d99a2fde87aeb989c9979378a758db3d06ddbcddefed859efc8b807553d52cc0
MD5 4fbb95f2dfac3d6f6f20f602823e2818
BLAKE2b-256 ca7316ae3d1e2e43a8c6e2e83718358fe31a6c452eb1db33ac763438071d022d

See more details on using hashes here.

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