MCPcopy Index your code
hub / github.com/pyload/pyload / getPropertyValue

Method getPropertyValue

module/lib/feedparser.py:2057–2139  ·  view source on GitHub ↗
(self, elmRoot, sProperty, iPropertyType=4, bAllowMultiple=0, bAutoEscape=0)

Source from the content-addressed store, hash-verified

2055 return time.strftime('%Y-%m-%dT%H:%M:%SZ', dt)
2056
2057 def getPropertyValue(self, elmRoot, sProperty, iPropertyType=4, bAllowMultiple=0, bAutoEscape=0):
2058 all = lambda x: 1
2059 sProperty = sProperty.lower()
2060 bFound = 0
2061 bNormalize = 1
2062 propertyMatch = {'class': re.compile(r'\b%s\b' % sProperty)}
2063 if bAllowMultiple and (iPropertyType != self.NODE):
2064 snapResults = []
2065 containers = elmRoot(['ul', 'ol'], propertyMatch)
2066 for container in containers:
2067 snapResults.extend(container('li'))
2068 bFound = (len(snapResults) != 0)
2069 if not bFound:
2070 snapResults = elmRoot(all, propertyMatch)
2071 bFound = (len(snapResults) != 0)
2072 if (not bFound) and (sProperty == 'value'):
2073 snapResults = elmRoot('pre')
2074 bFound = (len(snapResults) != 0)
2075 bNormalize = not bFound
2076 if not bFound:
2077 snapResults = [elmRoot]
2078 bFound = (len(snapResults) != 0)
2079 arFilter = []
2080 if sProperty == 'vcard':
2081 snapFilter = elmRoot(all, propertyMatch)
2082 for node in snapFilter:
2083 if node.findParent(all, propertyMatch):
2084 arFilter.append(node)
2085 arResults = []
2086 for node in snapResults:
2087 if node not in arFilter:
2088 arResults.append(node)
2089 bFound = (len(arResults) != 0)
2090 if not bFound:
2091 if bAllowMultiple: return []
2092 elif iPropertyType == self.STRING: return ''
2093 elif iPropertyType == self.DATE: return None
2094 elif iPropertyType == self.URI: return ''
2095 elif iPropertyType == self.NODE: return None
2096 else: return None
2097 arValues = []
2098 for elmResult in arResults:
2099 sValue = None
2100 if iPropertyType == self.NODE:
2101 if bAllowMultiple:
2102 arValues.append(elmResult)
2103 continue
2104 else:
2105 return elmResult
2106 sNodeName = elmResult.name.lower()
2107 if (iPropertyType == self.EMAIL) and (sNodeName == 'a'):
2108 sValue = (elmResult.get('href') or '').split('mailto:').pop().split('?')[0]
2109 if sValue:
2110 sValue = bNormalize and self.normalize(sValue) or sValue.strip()
2111 if (not sValue) and (sNodeName == 'abbr'):
2112 sValue = elmResult.get('title')
2113 if sValue:
2114 sValue = bNormalize and self.normalize(sValue) or sValue.strip()

Callers 7

findVCardsMethod · 0.95
processSingleStringMethod · 0.95
processSingleURIMethod · 0.95
processTypeValueMethod · 0.95
OaFunction · 0.80
OaFunction · 0.80

Calls 12

normalizeMethod · 0.95
vcardEscapeMethod · 0.95
_parse_date_iso8601Function · 0.85
compileMethod · 0.80
extendMethod · 0.80
findParentMethod · 0.80
splitMethod · 0.80
popMethod · 0.80
renderContentsMethod · 0.80
appendMethod · 0.45
getMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected