kopia lustrzana https://github.com/collective/icalendar
Some editing, rewrapping.
rodzic
b9877e1df0
commit
016042b9a4
|
@ -51,8 +51,8 @@ The root component is the VCALENDAR.
|
|||
... vcalendar properties ...
|
||||
END:VCALENDAR
|
||||
|
||||
The most frequent subcomponent to a VCALENDAR is a VEVENT. They are nested like
|
||||
this:
|
||||
The most frequent subcomponent to a VCALENDAR is a VEVENT. They are
|
||||
nested like this:
|
||||
|
||||
BEGIN:VCALENDAR
|
||||
... vcalendar properties ...
|
||||
|
@ -61,9 +61,9 @@ this:
|
|||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
|
||||
Inside the components there are properties with values. The values have special
|
||||
types. like integer, text, datetime etc. These values are encoded in a special
|
||||
text format in an iCalendar file.
|
||||
Inside the components there are properties with values. The values
|
||||
have special types. like integer, text, datetime etc. These values are
|
||||
encoded in a special text format in an iCalendar file.
|
||||
|
||||
There are methods for converting to and from these encodings in the package.
|
||||
|
||||
|
@ -95,8 +95,8 @@ str(cal) does the same):
|
|||
>>> str(cal)
|
||||
'BEGIN:VCALENDAR\r\nDTSTART:20050404T080000\r\nSUMMARY:Python meeting about calendaring\r\nEND:VCALENDAR\r\n'
|
||||
|
||||
in the calendar examples below the as_string() is implied. The rendered view is
|
||||
easier to read:
|
||||
in the calendar examples below the as_string() is implied. The
|
||||
rendered view is easier to read:
|
||||
|
||||
BEGIN:VCALENDAR
|
||||
DTSTART:20050404T080000
|
||||
|
@ -114,9 +114,10 @@ ATTENDEE:MAILTO:test@example.com
|
|||
END:VCALENDAR
|
||||
|
||||
|
||||
if you don't want to care about whether a property value is a list or a single
|
||||
value, just use the add() method. It will automatically convert the property to
|
||||
a list of values if more than one value is added.
|
||||
if you don't want to care about whether a property value is a list or
|
||||
a single value, just use the add() method. It will automatically
|
||||
convert the property to a list of values if more than one value is
|
||||
added.
|
||||
|
||||
>>> cal = Calendar()
|
||||
>>> cal.add('attendee', 'MAILTO:maxm@mxm.dk')
|
||||
|
@ -136,8 +137,9 @@ component.
|
|||
Subcomponents
|
||||
-------------
|
||||
|
||||
Any component can have subcomponents. Eg. inside a calendar there can be events.
|
||||
They can be arbitrarily nested. First by making a new component:
|
||||
Any component can have subcomponents. Eg. inside a calendar there can
|
||||
be events. They can be arbitrarily nested. First by making a new
|
||||
component:
|
||||
|
||||
>>> event = Event()
|
||||
>>> event['uid'] = '42'
|
||||
|
@ -166,16 +168,17 @@ Value types
|
|||
|
||||
Property values are utf-8 encoded strings.
|
||||
|
||||
This is impractical if you want to use the data for further computation. Eg. the
|
||||
datetime format looks like this: '20050404T080000'. But the package makes it
|
||||
simple to Parse and generate iCalendar formatted strings.
|
||||
This is impractical if you want to use the data for further
|
||||
computation. Eg. the datetime format looks like this:
|
||||
'20050404T080000'. But the package makes it simple to Parse and
|
||||
generate iCalendar formatted strings.
|
||||
|
||||
Basically you can make the add() method do the thinking, or you can do it
|
||||
yourself.
|
||||
|
||||
To add a datetime value, you can use Pythons built in datetime types, and the
|
||||
set the encode parameter to true, and it will convert to the type defined in the
|
||||
spec.
|
||||
To add a datetime value, you can use Pythons built in datetime types,
|
||||
and the set the encode parameter to true, and it will convert to the
|
||||
type defined in the spec.
|
||||
|
||||
>>> from datetime import datetime
|
||||
>>> cal.add('dtstart', datetime(2005,4,4,8,0,0))
|
||||
|
@ -185,8 +188,8 @@ spec.
|
|||
If that doesn't work satisfactorily for some reason, you can also do it
|
||||
manually.
|
||||
|
||||
In 'PropertyValues.py', all the iCalendar data types are defined. Each type has
|
||||
a class that can parse and encode the type.
|
||||
In 'icalendar.prop', all the iCalendar data types are defined. Each
|
||||
type has a class that can parse and encode the type.
|
||||
|
||||
So if you want to do it manually ...
|
||||
|
||||
|
@ -195,8 +198,9 @@ So if you want to do it manually ...
|
|||
>>> vDatetime(now).ical()
|
||||
'20050404T080000'
|
||||
|
||||
So the drill is to initialise the object with a python built in type, and then
|
||||
call the "ical()" method on the object. That will return an ical encoded string.
|
||||
So the drill is to initialise the object with a python built in type,
|
||||
and then call the "ical()" method on the object. That will return an
|
||||
ical encoded string.
|
||||
|
||||
You can do it the other way around too. To parse an encoded string, just call
|
||||
the "from_ical()" method, and it will return an instance of the corresponding
|
||||
|
@ -224,8 +228,8 @@ value directly.
|
|||
Example
|
||||
-------
|
||||
|
||||
Here is an example generating a complete iCal calendar file with a single event
|
||||
that can be loaded into the Mozilla calendar
|
||||
Here is an example generating a complete iCal calendar file with a
|
||||
single event that can be loaded into the Mozilla calendar
|
||||
|
||||
Init the calendar
|
||||
>>> cal = Calendar()
|
||||
|
|
Ładowanie…
Reference in New Issue