Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://pypi.python.org/pypi/icalendar" rel="noreferrer">The <code>icalendar</code> package</a> looks nice.</p> <p>For instance, to write a file:</p> <pre><code>from icalendar import Calendar, Event from datetime import datetime from pytz import UTC # timezone cal = Calendar() 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.to_ical()) f.close() </code></pre> <p>Tadaaa, you get this file:</p> <pre><code>BEGIN:VCALENDAR PRODID:-//My calendar product//mxm.dk// VERSION:2.0 BEGIN:VEVENT DTEND;VALUE=DATE:20050404T100000Z DTSTAMP;VALUE=DATE:20050404T001000Z DTSTART;VALUE=DATE:20050404T080000Z PRIORITY:5 SUMMARY:Python meeting about calendaring UID:20050115T101010/27346262376@mxm.dk END:VEVENT END:VCALENDAR </code></pre> <p>But what lies in this file?</p> <pre><code>g = open('example.ics','rb') gcal = Calendar.from_ical(g.read()) for component in gcal.walk(): print component.name g.close() </code></pre> <p>You can see it easily:</p> <pre><code>&gt;&gt;&gt; VCALENDAR VEVENT &gt;&gt;&gt; </code></pre> <p>What about parsing the data about the events:</p> <pre><code>g = open('example.ics','rb') gcal = Calendar.from_ical(g.read()) for component in gcal.walk(): if component.name == "VEVENT": print(component.get('summary')) print(component.get('dtstart')) print(component.get('dtend')) print(component.get('dtstamp')) g.close() </code></pre> <p>Now you get:</p> <pre><code>&gt;&gt;&gt; Python meeting about calendaring 20050404T080000Z 20050404T100000Z 20050404T001000Z &gt;&gt;&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload