(self, elmRoot, sProperty, iPropertyType=4, bAllowMultiple=0, bAutoEscape=0)
| 2141 | return time.strftime('%Y-%m-%dT%H:%M:%SZ', dt) |
| 2142 | |
| 2143 | def getPropertyValue(self, elmRoot, sProperty, iPropertyType=4, bAllowMultiple=0, bAutoEscape=0): |
| 2144 | all = lambda x: 1 |
| 2145 | sProperty = sProperty.lower() |
| 2146 | bFound = 0 |
| 2147 | bNormalize = 1 |
| 2148 | propertyMatch = {'class': re.compile(r'\b%s\b' % sProperty)} |
| 2149 | if bAllowMultiple and (iPropertyType != self.NODE): |
| 2150 | snapResults = [] |
| 2151 | containers = elmRoot(['ul', 'ol'], propertyMatch) |
| 2152 | for container in containers: |
| 2153 | snapResults.extend(container('li')) |
| 2154 | bFound = (len(snapResults) != 0) |
| 2155 | if not bFound: |
| 2156 | snapResults = elmRoot(all, propertyMatch) |
| 2157 | bFound = (len(snapResults) != 0) |
| 2158 | if (not bFound) and (sProperty == 'value'): |
| 2159 | snapResults = elmRoot('pre') |
| 2160 | bFound = (len(snapResults) != 0) |
| 2161 | bNormalize = not bFound |
| 2162 | if not bFound: |
| 2163 | snapResults = [elmRoot] |
| 2164 | bFound = (len(snapResults) != 0) |
| 2165 | arFilter = [] |
| 2166 | if sProperty == 'vcard': |
| 2167 | snapFilter = elmRoot(all, propertyMatch) |
| 2168 | for node in snapFilter: |
| 2169 | if node.findParent(all, propertyMatch): |
| 2170 | arFilter.append(node) |
| 2171 | arResults = [] |
| 2172 | for node in snapResults: |
| 2173 | if node not in arFilter: |
| 2174 | arResults.append(node) |
| 2175 | bFound = (len(arResults) != 0) |
| 2176 | if not bFound: |
| 2177 | if bAllowMultiple: |
| 2178 | return [] |
| 2179 | elif iPropertyType == self.STRING: |
| 2180 | return '' |
| 2181 | elif iPropertyType == self.DATE: |
| 2182 | return None |
| 2183 | elif iPropertyType == self.URI: |
| 2184 | return '' |
| 2185 | elif iPropertyType == self.NODE: |
| 2186 | return None |
| 2187 | else: |
| 2188 | return None |
| 2189 | arValues = [] |
| 2190 | for elmResult in arResults: |
| 2191 | sValue = None |
| 2192 | if iPropertyType == self.NODE: |
| 2193 | if bAllowMultiple: |
| 2194 | arValues.append(elmResult) |
| 2195 | continue |
| 2196 | else: |
| 2197 | return elmResult |
| 2198 | sNodeName = elmResult.name.lower() |
| 2199 | if (iPropertyType == self.EMAIL) and (sNodeName == 'a'): |
| 2200 | sValue = (elmResult.get('href') or '').split('mailto:').pop().split('?')[0] |
no test coverage detected