(self, elmRoot, bAgentParsing=0)
| 2235 | return arValues |
| 2236 | |
| 2237 | def findVCards(self, elmRoot, bAgentParsing=0): |
| 2238 | sVCards = '' |
| 2239 | |
| 2240 | if not bAgentParsing: |
| 2241 | arCards = self.getPropertyValue(elmRoot, 'vcard', bAllowMultiple=1) |
| 2242 | else: |
| 2243 | arCards = [elmRoot] |
| 2244 | |
| 2245 | for elmCard in arCards: |
| 2246 | arLines = [] |
| 2247 | |
| 2248 | def processSingleString(sProperty): |
| 2249 | sValue = self.getPropertyValue(elmCard, sProperty, self.STRING, bAutoEscape=1).decode(self.encoding) |
| 2250 | if sValue: |
| 2251 | arLines.append(self.vcardFold(sProperty.upper() + ':' + sValue)) |
| 2252 | return sValue or u'' |
| 2253 | |
| 2254 | def processSingleURI(sProperty): |
| 2255 | sValue = self.getPropertyValue(elmCard, sProperty, self.URI) |
| 2256 | if sValue: |
| 2257 | sContentType = '' |
| 2258 | sEncoding = '' |
| 2259 | sValueKey = '' |
| 2260 | if sValue.startswith('data:'): |
| 2261 | sEncoding = ';ENCODING=b' |
| 2262 | sContentType = sValue.split(';')[0].split('/').pop() |
| 2263 | sValue = sValue.split(',', 1).pop() |
| 2264 | else: |
| 2265 | elmValue = self.getPropertyValue(elmCard, sProperty) |
| 2266 | if elmValue: |
| 2267 | if sProperty != 'url': |
| 2268 | sValueKey = ';VALUE=uri' |
| 2269 | sContentType = elmValue.get('type', '').strip().split('/').pop().strip() |
| 2270 | sContentType = sContentType.upper() |
| 2271 | if sContentType == 'OCTET-STREAM': |
| 2272 | sContentType = '' |
| 2273 | if sContentType: |
| 2274 | sContentType = ';TYPE=' + sContentType.upper() |
| 2275 | arLines.append(self.vcardFold(sProperty.upper() + sEncoding + sContentType + sValueKey + ':' + sValue)) |
| 2276 | |
| 2277 | def processTypeValue(sProperty, arDefaultType, arForceType=None): |
| 2278 | arResults = self.getPropertyValue(elmCard, sProperty, bAllowMultiple=1) |
| 2279 | for elmResult in arResults: |
| 2280 | arType = self.getPropertyValue(elmResult, 'type', self.STRING, 1, 1) |
| 2281 | if arForceType: |
| 2282 | arType = self.unique(arForceType + arType) |
| 2283 | if not arType: |
| 2284 | arType = arDefaultType |
| 2285 | sValue = self.getPropertyValue(elmResult, 'value', self.EMAIL, 0) |
| 2286 | if sValue: |
| 2287 | arLines.append(self.vcardFold(sProperty.upper() + ';TYPE=' + ','.join(arType) + ':' + sValue)) |
| 2288 | |
| 2289 | # AGENT |
| 2290 | # must do this before all other properties because it is destructive |
| 2291 | # (removes nested class="vcard" nodes so they don't interfere with |
| 2292 | # this vcard's other properties) |
| 2293 | arAgent = self.getPropertyValue(elmCard, 'agent', bAllowMultiple=1) |
| 2294 | for elmAgent in arAgent: |
no test coverage detected