disabled
  L   ˆl–Ü4ý( ©¤ýÔâ€zàAq¶TÅ£�þB g+�<ÛàsùÐƒh¹Ïa–Ü4ý( ©¤ýÔâ€zã,Ü*bÑ¿Í      disabled
  4   ˆl–ßi~”ªn-j�vãM\dJbÑ¿ŽþDÔ‹6WÆFDØÆ ùÒ589Ñ¿Î M    €}q (X	   locale_idqX   en_VGqX   territoriesq}qX	   languagesq}qX   variantsq}qX   scriptsq	}q
X   list_patternsq}qX	   week_dataq}qX   zone_formatsq}qX
   time_zonesq}qX
   meta_zonesq}qX   number_symbolsq}qX   decimal_formatsq}qX   scientific_formatsq}qX   percent_formatsq}qX   currency_formatsq}qX   currency_unit_patternsq}q X   currency_namesq!}q"X   currency_names_pluralq#}q$X   currency_symbolsq%}q&X   unit_patternsq'}q(X   compound_unit_patternsq)}q*X   unit_display_namesq+}q,X   date_fieldsq-}q.X   measurement_systemsq/}q0u.  7   ˆl–ß=¿J¥2ÛB‚ „ �pM\ŠbÑ¿�þZl Y²²GÇ+ÁŒ€óÓ„®8×ÒÑÀÏ ?÷     # This file is part of Radicale - CalDAV and CardDAV server
# Copyright Â© 2008 Nicolas Kandel
# Copyright Â© 2008 Pascal Halter
# Copyright Â© 2008-2017 Guillaume Ayoub
# Copyright Â© 2017-2018 Unrud <unrud@outlook.com>
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Radicale.  If not, see <http://www.gnu.org/licenses/>.

import collections
import itertools
import posixpath
import socket
import xml.etree.ElementTree as ET
from http import client
from typing import Dict, Iterable, Iterator, List, Optional, Sequence, Tuple

from radicale import httputils, pathutils, rights, storage, types, xmlutils
from radicale.app.base import Access, ApplicationBase
from radicale.log import logger


def xml_propfind(base_prefix: str, path: str,
                 xml_request: Optional[ET.Element],
                 allowed_items: Iterable[Tuple[types.CollectionOrItem, str]],
                 user: str, encoding: str) -> Optional[ET.Element]:
    """Read and answer PROPFIND requests.

    Read rfc4918-9.1 for info.

    The collections parameter is a list of collections that are to be included
    in the output.

    """
    # A client may choose not to submit a request body.  An empty PROPFIND
    # request body MUST be treated as if it were an 'allprop' request.
    top_element = (xml_request[0] if xml_request is not None else
                   ET.Element(xmlutils.make_clark("D:allprop")))

    props: List[str] = []
    allprop = False
    propname = False
    if top_element.tag == xmlutils.make_clark("D:allprop"):
        allprop = True
    elif top_element.tag == xmlutils.make_clark("D:propname"):
        propname = True
    elif top_element.tag == xmlutils.make_clark("D:prop"):
        props.extend(prop.tag for prop in top_element)

    if xmlutils.make_clark("D:current-user-principal") in props and not user:
        # Ask for authentication
        # Returning the DAV:unauthenticated pseudo-principal as specified in
        # RFC 5397 doesn't seem to work with DAVx5.
        return None

    # Writing answer
    multistatus = ET.Element(xmlutils.make_clark("D:multistatus"))

    for item, permission in allowed_items:
        write = permission == "w"
        multistatus.append(xml_propfind_response(
            base_prefix, path, item, props, user, encoding, write=write,
            allprop=allprop, propname=propname))

    return multistatus


def xml_propfind_response(
        base_prefix: str, path: str, item: types.CollectionOrItem,
        props: Sequence[str], user: str, encoding: str, write: bool = False,
        propname: bool = False, allprop: bool = False) -> ET.Element:
    """Build and return a PROPFIND response."""
    if propname and allprop or (props and (propname or allpr