MCPcopy Index your code
hub / github.com/clips/pattern / getPropertyValue

Method getPropertyValue

pattern/web/feed/feedparser.py:2143–2235  ·  view source on GitHub ↗
(self, elmRoot, sProperty, iPropertyType=4, bAllowMultiple=0, bAutoEscape=0)

Source from the content-addressed store, hash-verified

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]

Callers 4

findVCardsMethod · 0.95
processSingleStringMethod · 0.95
processSingleURIMethod · 0.95
processTypeValueMethod · 0.95

Calls 12

normalizeMethod · 0.95
vcardEscapeMethod · 0.95
lenFunction · 0.85
_parse_date_iso8601Function · 0.85
findParentMethod · 0.80
stripMethod · 0.80
renderContentsMethod · 0.80
extendMethod · 0.45
appendMethod · 0.45
splitMethod · 0.45
popMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected