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

Method startElementNS

pattern/web/feed/feedparser.py:1796–1841  ·  view source on GitHub ↗
(self, name, qname, attrs)

Source from the content-addressed store, hash-verified

1794 self.decls['xmlns:' + prefix] = uri
1795
1796 def startElementNS(self, name, qname, attrs):
1797 namespace, localname = name
1798 lowernamespace = str(namespace or '').lower()
1799 if lowernamespace.find(u'backend.userland.com/rss') <> -1:
1800 # match any backend.userland.com namespace
1801 namespace = u'http://backend.userland.com/rss'
1802 lowernamespace = namespace
1803 if qname and qname.find(':') > 0:
1804 givenprefix = qname.split(':')[0]
1805 else:
1806 givenprefix = None
1807 prefix = self._matchnamespaces.get(lowernamespace, givenprefix)
1808 if givenprefix and (prefix == None or (prefix == '' and lowernamespace == '')) and givenprefix not in self.namespacesInUse:
1809 raise UndeclaredNamespace, "'%s' is not associated with a namespace" % givenprefix
1810 localname = str(localname).lower()
1811
1812 # qname implementation is horribly broken in Python 2.1 (it
1813 # doesn't report any), and slightly broken in Python 2.2 (it
1814 # doesn't report the xml: namespace). So we match up namespaces
1815 # with a known list first, and then possibly override them with
1816 # the qnames the SAX parser gives us (if indeed it gives us any
1817 # at all). Thanks to MatejC for helping me test this and
1818 # tirelessly telling me that it didn't work yet.
1819 attrsD, self.decls = self.decls, {}
1820 if localname=='math' and namespace=='http://www.w3.org/1998/Math/MathML':
1821 attrsD['xmlns']=namespace
1822 if localname=='svg' and namespace=='http://www.w3.org/2000/svg':
1823 attrsD['xmlns']=namespace
1824
1825 if prefix:
1826 localname = prefix.lower() + ':' + localname
1827 elif namespace and not qname: #Expat
1828 for name,value in self.namespacesInUse.items():
1829 if name and value == namespace:
1830 localname = name + ':' + localname
1831 break
1832
1833 for (namespace, attrlocalname), attrvalue in attrs.items():
1834 lowernamespace = (namespace or '').lower()
1835 prefix = self._matchnamespaces.get(lowernamespace, '')
1836 if prefix:
1837 attrlocalname = prefix + ':' + attrlocalname
1838 attrsD[str(attrlocalname).lower()] = attrvalue
1839 for qname in attrs.getQNames():
1840 attrsD[str(qname).lower()] = attrs.getValueByQName(qname)
1841 self.unknown_starttag(localname, attrsD.items())
1842
1843 def characters(self, text):
1844 self.handle_data(text)

Callers

nothing calls this directly

Calls 6

strFunction · 0.85
findMethod · 0.45
splitMethod · 0.45
getMethod · 0.45
itemsMethod · 0.45
unknown_starttagMethod · 0.45

Tested by

no test coverage detected