本文整理汇总了Python中elementtree.ElementTree.Element.attrib['uri']方法的典型用法代码示例。如果您正苦于以下问题:Python Element.attrib['uri']方法的具体用法?Python Element.attrib['uri']怎么用?Python Element.attrib['uri']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elementtree.ElementTree.Element
的用法示例。
在下文中一共展示了Element.attrib['uri']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: modify
# 需要导入模块: from elementtree.ElementTree import Element [as 别名]
# 或者: from elementtree.ElementTree.Element import attrib['uri'] [as 别名]
def modify(self):
assert self.feed.feedURL, 'feedURL must be provided'
assert self.feed.webURL, 'webURL must be provided'
assert self.feed.baseURL, 'baseURL must be provided'
assert self.feed.uid, 'uid must be provided'
####################################
# feed element RFC4248 Section 4.1.1
root = self.tree.getroot()
root.attrib['{%s}base' % xmlns] = self.feed.baseURL
#############################################
# let metadata appear before all feedentries.
self.modifyMetadata(self.feed, root)
#########################################
# generator element RFC4248 Section 4.2.4
gen = self.feed.generator
assert(isinstance(gen, dict), 'generator is provided, but not a '
'dict instance')
el = Element(self.namespace+'generator')
el.text = cgi.escape(gen.get('text', 'cornerstone.feed'))
if gen.get('uri', None):
el.attrib['uri'] = gen.get('uri')
if gen.get('version', None):
el.attrib['version'] = gen.get('version')
root.append(el)
# icon element RFC4248 Section 4.2.5
if self.feed.iconURL:
el = Element(self.namespace+'icon')
el.text = self.feed.iconURL
root.append(el)
# link elements RFC4248 Section 4.2.7
if self.feed.feedURL:
root.append(createLink(self.feed.feedURL, 'self'))
if self.feed.webURL:
root.append(createLink(self.feed.feedURL, 'alternate'))
# logo element RFC4248 Section 4.2.8
if self.feed.imageURL:
el = Element(self.namespace+'logo')
el.text = self.feed.imageURL
root.append(el)
#####################################
# entry element RFC4248 Section 4.1.2
producer = getUtility(IAtomFeedEntrySkeletonProducer)
namespaces = Set([self.namespace, xmlns])
for entry in self.feed.getFeedEntries():
node = producer()
named_modifiers = list(getAdapters((entry, node),
IFeedEntryModifier))
named_modifiers.sort(key=operator.itemgetter(0))
for name, modifier in named_modifiers:
ns = modifier.modify()
namespaces.update(ns)
root.append(node)
return namespaces