API Referenceļ
Create compatibility access for icalendar components.
- class Description(event: Event)[source]ļ
Event description compatibility.
This includes HTML and text description.
Example:
>>> from icalendar import Event >>> from icalendar_compatibility import Description >>> event_string = ''' ... BEGIN:VEVENT ... SUMMARY:Eventwith HTML ... DTSTART;TZID=Europe/London:20240414T090000 ... DESCRIPTION;ALTREP="data:text/html,%3Ch1%3EKnow%20This%20Heading!%3C%2Fh1%3 ... E%3Cbr%3EPlease%20have%20a%20look%20at%20this%20website%3A%3Cbr%3E%3Ca%20hr ... ef%3D%22https%3A%2F%2Fopen-web-calendar.quelltext.eu%2Ftemplates%2F%22%3EEx ... amples%3C%2Fa%3E%3Cbr%3E%F0%9F%99%82%3Col%3E%3Cli%3Eone%3C%2Fli%3E%3Cli%3Et ... wo%3C%2Fli%3E%3C%2Fol%3EAnd%20consider%20this%3A%3Cul%3E%3Cli%3Ea%20bullet% ... 20point%3C%2Fli%3E%3Cli%3Eand%20another%20bullet%20point%3C%2Fli%3E%3C%2Ful ... %3E%3Cp%3E%3Cb%3Ebold%3C%2Fb%3E%2C%20%3Cu%3Eunderlined%3C%2Fu%3E%20and%20%3 ... Ci%3Eitalic%3C%2Fi%3E%20work!%3C%2Fp%3E%3Cpre%3Ecode%3Cbr%3Ecode%3Cbr%3Ecod ... e%3C%2Fpre%3E":Know This Heading!\\n\\nPlease have a look at this website:\\nE ... xamples\\nš\\n\\n one\\n two\\n\\nAnd consider this:\\n\\n a bullet poi ... nt\\n and another bullet point\\n\\nbold\\, underlined and italic work!\\n\\nc ... ode\\ncode\\ncode ... END:VEVENT ... ''' >>> event = Event.from_ical(event_string) >>> description = Description(event) >>> description.html[:49] '<h1>Know This Heading!</h1><br>Please have a look' >>> description.text[:38] 'Know This Heading!\n\nPlease have a look'
Note
Please note that sometimes there is an HTML description but not a text description.
>>> event_string = ''' ... BEGIN:VEVENT ... SUMMARY:Eventwith HTML ... DTSTART;TZID=Europe/London:20240414T090000 ... DESCRIPTION:<p>HTML description</p> ... END:VEVENT ... ''' >>> event = Event.from_ical(event_string) >>> description = Description(event) >>> description.html '<p>HTML description</p>' >>> description.text ''
- class Location(event: Event, spec: LocationSpec | None = None)[source]ļ
The location of an event.
- Attributes:
- textstr
The text of the location.
- urlstr
The url of the event location. This considers geo information, text and more.
Examples:
>>> from icalendar_compatibility import Location, LocationSpec >>> from icalendar import Event >>> event_string = ''' ... BEGIN:VEVENT ... SUMMARY:Event in Mountain View with Geo link ... DTSTART:20250115T150000Z ... LOCATION:Mountain View, Santa Clara County, Kalifornien, Vereinigte Staaten von Amerika ... GEO:37.386013;-122.082932 ... END:VEVENT ... ''' >>> event = Event.from_ical(event_string) >>> location = Location(event, LocationSpec.for_bing_com()) >>> print(location.text) Mountain View, Santa Clara County, Kalifornien, Vereinigte Staaten von Amerika >>> print(location.url) https://www.bing.com/maps?brdr=1&cp=37.386013%7E-122.082932&lvl=16
- property lat: float | Noneļ
The latitude of the location.
- Returns: float
The longitude or None if we have no location data.
- property lon: float | Noneļ
The longitude of the location.
- Returns: float
The longitude or None if we have no location data.
- property raw_altrep: strļ
The alternative representation according to RFC5545.
LOCATION;ALTREP="http://xyzcorp.com/conf-rooms/f123.vcf": Conference Room - F123\, Bldg. 002
- property raw_text: vTextļ
The raw event text of the location.
LOCATION:Conference Room - F123\, Bldg. 002
- property spec: LocationSpecļ
The location spec we use.
- property text: strļ
The location text.
- Returns: str
The text or an empty string if we have no location data.
- class LocationSpec(geo_url: str, text_url: str, zoom: int = 16)[source]ļ
Specification for event locations.
- Attributes:
- zoomint
Zoom level for geo_url and search_url
- geo_urlstr
A url template when the geo location is given. At least {lat} and {lon} are required.
- text_urlstr
A url template when the location is given as text. At leat {location} is required.
Examples:
>>> from icalendar_compatibility import LocationSpec >>> spec = LocationSpec.for_openstreetmap_org()
- classmethod for_bing_com(**kw) LocationSpec[source]ļ
Spec for https://www.bing.com/maps
- classmethod for_geo_url() LocationSpec[source]ļ
Spec for the geo:{lat},{lon} links.
geo:48.2010,16.3695
- classmethod for_google_co_uk(**kw) LocationSpec[source]ļ
Spec for https://www.google.co.uk/maps
- classmethod for_google_com(**kw) LocationSpec[source]ļ
Spec for https://www.google.com/maps
- classmethod for_no_url() LocationSpec[source]ļ
Return a spec that creates empty URLs always.
- classmethod for_openstreetmap_org(**kw) LocationSpec[source]ļ
Spec for https://openstreetmap.org
- get_geo_url(*, lat: float, lon: float, zoom: int | None = None) str[source]ļ
Get the url for a geo location.