| Home | Trees | Indices | Help |
|---|
|
|
1 ## 2 # Copyright (c) 2007-2016 Apple Inc. All rights reserved. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 ## 16 17 from caldavclientlibrary.protocol.webdav.multiresponseparser import MultiResponseParser 18 from caldavclientlibrary.protocol.webdav.definitions import davxml 19 from caldavclientlibrary.protocol.http.util import parseStatusLine 20 from xml.etree.ElementTree import QName 21 from caldavclientlibrary.protocol.url import URL 2224 25 textProperties = set() 26 hrefProperties = set() 27 hrefListProperties = set() 28169306732 self.status = None 33 self.textProperties = {} 34 self.hrefProperties = {} 35 self.nodeProperties = {} 36 self.badProperties = {}37 42 47 52 5759 self.nodeProperties[name] = node61 return self.nodeProperties6266 return self.badProperties69 self.results = {}7072 return self.results73 74 # Parse the response element down to the properties76 # Verify that the node is the correct element <DAV:response> 77 if response.tag != davxml.response: 78 return 79 80 # Node is the right type, so iterate over all child response nodes and process each one 81 result = PropFindParser.PropFindResult() 82 for child in response.getchildren(): 83 84 # Is it the href 85 if child.tag == davxml.href: 86 result.setResource(child.text) 87 88 # Is it propstat 89 elif child.tag == davxml.propstat: 90 self.parsePropStat(child, result) 91 92 elif child.tag == davxml.status: 93 result.setStatus(child.text) 94 95 # Add the resource only if we got one 96 if result.getResource(): 97 self.results[result.getResource()] = result98100 # Scan the propstat node the status - we only process OK status 101 102 # Now look for a <DAV:status> element in its children 103 status = propstat.find(str(davxml.status)) 104 105 # Now parse the response and dispatch accordingly 106 if status is not None: 107 108 status_result = parseStatusLine(status.text) 109 badstatus = status_result if status_result / 100 != 2 else None 110 111 # Now look for a <DAV:prop> element in its children 112 for item in propstat.findall(str(davxml.prop)): 113 self.parseProp(item, result, badstatus)114116 # Scan the prop node - each child is processed 117 for item in property.getchildren(): 118 self.parsePropElement(item, result, badstatus)119 120 # Parsing of property elements122 # Here we need to detect the type of element and dispatch accordingly 123 if badstatus: 124 result.addBadProperty(QName(prop.tag), badstatus) 125 126 # Determine what type of content we have 127 else: 128 children = prop.getchildren() 129 children_length = len(children) 130 if children_length == 0: 131 self.parsePropElementText(prop, result) 132 elif prop.text is None or not prop.text.strip(): 133 if children_length == 1: 134 if children[0].tag == davxml.href: 135 self.parsePropElementHref(prop, result, False) 136 else: 137 self.parsePropElementUnknown(prop, result) 138 else: 139 allHref = True 140 for child in children: 141 if child.tag != davxml.href: 142 allHref = False 143 if allHref: 144 self.parsePropElementHref(prop, result, True) 145 else: 146 self.parsePropElementUnknown(prop, result) 147 else: 148 self.parsePropElementUnknown(prop, result)149151 # Grab the element data 152 result.addTextProperty(QName(prop.tag), prop.text if prop.text else "") 153 result.addNodeProperty(QName(prop.tag), prop)154156 # Grab the element data 157 hrefs = tuple([URL(url=href.text, decode=True) for href in prop.findall(str(davxml.href))]) 158 if not is_list: 159 if len(hrefs) == 1: 160 hrefs = hrefs[0] 161 else: 162 hrefs = "" 163 result.addHrefProperty(QName(prop.tag), hrefs) 164 result.addNodeProperty(QName(prop.tag), prop)165
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Thu Jul 7 15:01:50 2011 | http://epydoc.sourceforge.net |