kopia lustrzana https://github.com/collective/icalendar
Add Image class
rodzic
776dc2b7a7
commit
b0d98b004f
|
|
@ -51,6 +51,7 @@ from icalendar.parser import (
|
||||||
|
|
||||||
# Property Data Value Types
|
# Property Data Value Types
|
||||||
from icalendar.prop import (
|
from icalendar.prop import (
|
||||||
|
Image,
|
||||||
TypesFactory,
|
TypesFactory,
|
||||||
vBinary,
|
vBinary,
|
||||||
vBoolean,
|
vBoolean,
|
||||||
|
|
@ -106,6 +107,7 @@ __all__ = [
|
||||||
"Event",
|
"Event",
|
||||||
"FeatureWillBeRemovedInFutureVersion",
|
"FeatureWillBeRemovedInFutureVersion",
|
||||||
"FreeBusy",
|
"FreeBusy",
|
||||||
|
"Image",
|
||||||
"IncompleteAlarmInformation",
|
"IncompleteAlarmInformation",
|
||||||
"IncompleteComponent",
|
"IncompleteComponent",
|
||||||
"InvalidCalendar",
|
"InvalidCalendar",
|
||||||
|
|
|
||||||
|
|
@ -60,9 +60,10 @@ from icalendar.parser_tools import (
|
||||||
from_unicode,
|
from_unicode,
|
||||||
to_unicode,
|
to_unicode,
|
||||||
)
|
)
|
||||||
|
from icalendar.timezone import tzid_from_dt, tzid_from_tzinfo, tzp
|
||||||
from icalendar.tools import to_datetime
|
from icalendar.tools import to_datetime
|
||||||
|
|
||||||
from .timezone import tzid_from_dt, tzid_from_tzinfo, tzp
|
from .image import Image
|
||||||
|
|
||||||
DURATION_REGEX = re.compile(
|
DURATION_REGEX = re.compile(
|
||||||
r"([-+]?)P(?:(\d+)W)?(?:(\d+)D)?" r"(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$"
|
r"([-+]?)P(?:(\d+)W)?(?:(\d+)D)?" r"(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$"
|
||||||
|
|
@ -2208,6 +2209,7 @@ class TypesFactory(CaselessDict):
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"DURATION_REGEX",
|
"DURATION_REGEX",
|
||||||
"WEEKDAY_RULE",
|
"WEEKDAY_RULE",
|
||||||
|
"Image",
|
||||||
"TimeBase",
|
"TimeBase",
|
||||||
"TypesFactory",
|
"TypesFactory",
|
||||||
"tzid_from_dt",
|
"tzid_from_dt",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
"""This contains the IMAGE property from :rfc:`7986`."""
|
||||||
|
|
||||||
|
|
||||||
|
class Image:
|
||||||
|
"""An image as URI or BINARY according to :rfc:`7986`."""
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["Image"]
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
BEGIN:VCALENDAR
|
||||||
|
BEGIN:VEVENT
|
||||||
|
UID:uri-event
|
||||||
|
IMAGE;VALUE=URI;DISPLAY=BADGE;FMTTYPE=image/png:http://example.com/images/party.png
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VTODO
|
||||||
|
UID:uri-todo
|
||||||
|
IMAGE;VALUE=URI;DISPLAY=BADGE;FMTTYPE=image/jpg:http://example.com/images/party.jpg
|
||||||
|
END:VTODO
|
||||||
|
BEGIN:VJOURNAL
|
||||||
|
UID:uri-todo
|
||||||
|
IMAGE;VALUE=URI;DISPLAY=ICON;FMTTYPE=image/jpg:http://example.com/images/party.jpg
|
||||||
|
END:VJOURNAL
|
||||||
|
BEGIN:VEVENT
|
||||||
|
UID:data-event
|
||||||
|
IMAGE;ENCODING=BASE64;VALUE=BINARY;FMTTYPE=image/png:iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACXBIWXMAAAAnAAAAJwEqCZFPAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAA1JREFUCJlj+P//PwMACPwC/oXNqzQAAAAASUVORK5CYII=
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VTODO
|
||||||
|
UID:data-todo
|
||||||
|
IMAGE;ENCODING=BASE64;VALUE=BINARY;FMTTYPE=image/png;ALTREP=http://example.com/images/party.jpg:iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACXBIWXMAAAAnAAAAJwEqCZFPAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAA1JREFUCJlj+P//PwMACPwC/oXNqzQAAAAASUVORK5CYII=
|
||||||
|
END:VTODO
|
||||||
|
BEGIN:VJOURNAL
|
||||||
|
UID:data-journal
|
||||||
|
IMAGE;ENCODING=BASE64;VALUE=BINARY;FMTTYPE=image/png;DISPLAY=BADGE:iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACXBIWXMAAAAnAAAAJwEqCZFPAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAA1JREFUCJlj+P//PwMACPwC/oXNqzQAAAAASUVORK5CYII=
|
||||||
|
END:VJOURNAL
|
||||||
|
END:VCALENDAR
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
"""Test the image class to convert from and to binary data."""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def images(calendars):
|
||||||
|
"""Return the images we get from the example calendars."""
|
||||||
Ładowanie…
Reference in New Issue