Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
collection.calendar_query(filter_fn),
collection.subcollections())
async for (href, resource) in webdav.traverse_resource(
base_resource, base_href, depth,
members=members):
# Ideally traverse_resource would only return the right things.
if getattr(resource, 'content_type', None) == 'text/calendar':
propstat = davcommon.get_properties_with_data(
self.data_property, href, resource, properties, environ,
requested)
yield webdav.Status(
href, '200 OK', propstat=[s async for s in propstat])
class CalendarColorProperty(webdav.Property):
"""calendar-color property
This contains a HTML #RRGGBB color code, as CDATA.
"""
name = '{http://apple.com/ns/ical/}calendar-color'
resource_type = (CALENDAR_RESOURCE_TYPE, SUBSCRIPTION_RESOURCE_TYPE)
async def get_value(self, href, resource, el, environ):
el.text = resource.get_calendar_color()
async def set_value(self, href, resource, el):
resource.set_calendar_color(el.text)
class SupportedCalendarComponentSetProperty(webdav.Property):
class MaxAttachmentSizeProperty(webdav.Property):
"""max-attachment-size property.
https://tools.ietf.org/id/draft-ietf-calext-caldav-attachments-03.html#rfc.section.6.2
"""
name = '{%s}max-attachment-size' % NAMESPACE
resource_type = CALENDAR_RESOURCE_TYPE
in_allprops = False
live = True
async def get_value(self, href, resource, el, environ):
el.text = str(resource.get_max_attachment_size())
class ManagedAttachmentsServerURLProperty(webdav.Property):
"""managed-attachments-server-URL property.
https://tools.ietf.org/id/draft-ietf-calext-caldav-attachments-03.html#rfc.section.6.1
"""
name = '{%s}managed-attachments-server-URL' % NAMESPACE
in_allprops = False
async def get_value(self, base_href, resource, el, environ):
# The RFC specifies that this property can be set on a calendar home
# collection.
# However, there is no matching resource type and we don't want to
# force all resources to implement it. So we just check whether the
# attribute is present.
fn = getattr(resource, 'get_managed_attachments_server_url', None)
if fn is None:
name = '{urn:ietf:params:xml:ns:caldav}calendar-timezone'
resource_type = (CALENDAR_RESOURCE_TYPE,
SCHEDULE_INBOX_RESOURCE_TYPE)
in_allprops = False
async def get_value(self, href, resource, el, environ):
el.text = resource.get_calendar_timezone()
async def set_value(self, href, resource, el):
if el is not None:
resource.set_calendar_timezone(el.text)
else:
resource.set_calendar_timezone(None)
class MinDateTimeProperty(webdav.Property):
"""min-date-time property.
See https://tools.ietf.org/html/rfc4791, section 5.2.6
"""
name = '{urn:ietf:params:xml:ns:caldav}min-date-time'
resource_type = (CALENDAR_RESOURCE_TYPE,
SCHEDULE_INBOX_RESOURCE_TYPE,
SCHEDULE_OUTBOX_RESOURCE_TYPE)
in_allprops = False
live = True
async def get_value(self, href, resource, el, environ):
el.text = resource.get_min_date_time()
"""getctag property
"""
name = '{DAV:}getctag'
class AppleGetCTagProperty(GetCTagProperty):
"""getctag property
"""
name = '{http://calendarserver.org/ns/}getctag'
class RefreshRateProperty(Property):
"""refreshrate property.
(no public documentation, but contains an ical-style frequency indicator)
"""
name = '{http://calendarserver.org/ns/}refreshrate'
resource_type = COLLECTION_RESOURCE_TYPE
in_allprops = False
async def get_value(self, href, resource, el, environ):
el.text = resource.get_refreshrate()
def set_value(self, href, resource, el):
resource.set_refreshrate(el.text)
name = '{urn:ietf:params:xml:ns:caldav}supported-calendar-data'
resource_type = (CALENDAR_RESOURCE_TYPE,
SCHEDULE_INBOX_RESOURCE_TYPE,
SCHEDULE_OUTBOX_RESOURCE_TYPE)
in_allprops = False
async def get_value(self, href, resource, el, environ):
for (content_type, version) in (
resource.get_supported_calendar_data_types()):
subel = ET.SubElement(
el, '{urn:ietf:params:xml:ns:caldav}calendar-data')
subel.set('content-type', content_type)
subel.set('version', version)
class CalendarTimezoneProperty(webdav.Property):
"""calendar-timezone property.
See https://tools.ietf.org/html/rfc4791, section 5.2.2
"""
name = '{urn:ietf:params:xml:ns:caldav}calendar-timezone'
resource_type = (CALENDAR_RESOURCE_TYPE,
SCHEDULE_INBOX_RESOURCE_TYPE)
in_allprops = False
async def get_value(self, href, resource, el, environ):
el.text = resource.get_calendar_timezone()
async def set_value(self, href, resource, el):
if el is not None:
resource.set_calendar_timezone(el.text)
"""
name = '{%s}supported-address-data' % NAMESPACE
resource_type = ADDRESSBOOK_RESOURCE_TYPE
in_allprops = False
live = True
async def get_value(self, href, resource, el, environ):
for (content_type,
version) in resource.get_supported_address_data_types():
subel = ET.SubElement(el, '{%s}content-type' % NAMESPACE)
subel.set('content-type', content_type)
subel.set('version', version)
class MaxResourceSizeProperty(webdav.Property):
"""Provides the max-resource-size property.
See https://tools.ietf.org/html/rfc6352, section 6.2.3.
"""
name = '{%s}max-resource-size' % NAMESPACE
resource_type = ADDRESSBOOK_RESOURCE_TYPE
in_allprops = False
live = True
async def get_value(self, href, resource, el, environ):
el.text = str(resource.get_max_resource_size())
class MaxImageSizeProperty(webdav.Property):
"""Provides the max-image-size property.
"""
raise KeyError(self.name)
def set_value(self, href: str, resource: Resource, el: ET.Element) -> None:
"""Set property.
:param href: Resource href
:param resource: Resource to modify
:param el: Element to get new value from (None to remove property)
:raise NotImplementedError: to indicate this property can not be set
(i.e. is protected)
"""
raise NotImplementedError(self.set_value)
class ResourceTypeProperty(Property):
"""Provides {DAV:}resourcetype."""
name = '{DAV:}resourcetype'
resource_type = None
live = True
async def get_value(self, href, resource, el, environ):
for rt in resource.resource_types:
ET.SubElement(el, rt)
def set_value(self, href, resource, el):
resource.set_resource_types([e.tag for e in el])
class MaxAttachmentsPerResourceProperty(webdav.Property):
"""max-attachments-per-resource property.
https://tools.ietf.org/id/draft-ietf-calext-caldav-attachments-03.html#rfc.section.6.3
"""
name = '{%s}max-attachments-per-resource' % NAMESPACE
resource_type = CALENDAR_RESOURCE_TYPE
in_allprops = False
live = True
async def get_value(self, href, resource, el, environ):
el.text = str(resource.get_max_attachments_per_resource())
class MaxAttachmentSizeProperty(webdav.Property):
"""max-attachment-size property.
https://tools.ietf.org/id/draft-ietf-calext-caldav-attachments-03.html#rfc.section.6.2
"""
name = '{%s}max-attachment-size' % NAMESPACE
resource_type = CALENDAR_RESOURCE_TYPE
in_allprops = False
live = True
async def get_value(self, href, resource, el, environ):
el.text = str(resource.get_max_attachment_size())
class ManagedAttachmentsServerURLProperty(webdav.Property):
"""managed-attachments-server-URL property.
name = '{DAV:}principal-URL'
resource_type = '{DAV:}principal'
in_allprops = True
live = True
async def get_value(self, href, resource, el, environ):
"""Get property with specified name.
:param name: A property name.
"""
el.append(create_href(
ensure_trailing_slash(resource.get_principal_url()), href))
class SupportedReportSetProperty(Property):
name = '{DAV:}supported-report-set'
resource_type = '{DAV:}collection'
in_allprops = False
live = True
def __init__(self, reporters):
self._reporters = reporters
async def get_value(self, href, resource, el, environ):
for name, reporter in self._reporters.items():
if reporter.supported_on(resource):
bel = ET.SubElement(el, '{DAV:}supported-report')
ET.SubElement(bel, name)
def get_calendar_home_set(self):
"""Get the calendar home set.
:return: a set of URLs
"""
raise NotImplementedError(self.get_calendar_home_set)
def get_calendar_user_address_set(self):
"""Get the calendar user address set.
:return: a set of URLs (usually mailto:...)
"""
raise NotImplementedError(self.get_calendar_user_address_set)
class CalendarHomeSetProperty(webdav.Property):
"""calendar-home-set property
See https://www.ietf.org/rfc/rfc4791.txt, section 6.2.1.
"""
name = '{%s}calendar-home-set' % NAMESPACE
resource_type = '{DAV:}principal'
in_allprops = False
live = True
async def get_value(self, base_href, resource, el, environ):
for href in resource.get_calendar_home_set():
href = webdav.ensure_trailing_slash(href)
el.append(webdav.create_href(href, base_href))