Skip to main content

Python icalendar (rfc5545) parser

Project description

(Release 0.1.1)

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

Install using pip.

$ 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

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.2.tar.gz (10.4 kB view details)

Uploaded Source

File details

Details for the file ics-0.1.2.tar.gz.

File metadata

  • Download URL: ics-0.1.2.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ics-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c066bfd5c2ca980d04e21f9b0bb81d7b79a409e33016245b8fca0420d25c7685
MD5 04dd8e11e45c11d825e2882b03463a8f
BLAKE2b-256 8d326aa267a35dbe7da68b7cd3fac47ca3d97fe98bbeb36600fdb7f6a263dc83

See more details on using hashes here.

Supported by

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