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

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for ics-0.1.1.tar.gz
Algorithm Hash digest
SHA256 476a4796322dde5a59bd375304f421669e433c3cf3dca275618e8bc7ea1d8949
MD5 9da986731be9a38f520869a3768436a9
BLAKE2b-256 ef9b01d981679e94dba9aa8f88b1d6a83f53bfca008dc89ba47e2d33faca450a

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