本文整理汇总了Python中xml.etree.cElementTree.Element.attrib['xmlns:atom']方法的典型用法代码示例。如果您正苦于以下问题:Python Element.attrib['xmlns:atom']方法的具体用法?Python Element.attrib['xmlns:atom']怎么用?Python Element.attrib['xmlns:atom']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml.etree.cElementTree.Element
的用法示例。
在下文中一共展示了Element.attrib['xmlns:atom']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makerss
# 需要导入模块: from xml.etree.cElementTree import Element [as 别名]
# 或者: from xml.etree.cElementTree.Element import attrib['xmlns:atom'] [as 别名]
def makerss(titletext, top, root, files):
print 'Building %s' % os.path.join(root, 'photos.rss')
dirlen = len(top)+len(os.path.sep)
rootpath = root[dirlen:]
rootlen = len(rootpath) > 0 and len(rootpath)+len(os.path.sep) or 0
rss = Element('rss', version='2.0')
rss.attrib['xmlns:atom'] = NS_ATOM
rss.attrib['xmlns:media'] = NS_MEDIA
channel = SubElement(rss, 'channel')
title = SubElement(channel, 'title')
title.text = titletext
description = SubElement(channel, 'description')
description.text = _('This feed enables cooliris http://www.cooliris.com/ in your web browser')
channel.append(Comment('must have a link for rss'))
link = SubElement(channel, 'link')
link.text = 'http://localhost/'
result = []
for image in files:
imagepath = util.www_image_path(image, '.images')
if not options.noimages:
util.www_image_create(os.path.join(top, image), force=options.force, verbose=options.verbose)
thumbpath = util.www_image_path(image, '.thumbs')
if not options.nothumbs:
util.www_thumb_create(os.path.join(top, image), force=options.force, verbose=options.verbose)
if options.verbose >= 3:
print 'rootpath:', rootpath, 'image:', image, 'imagepath:', imagepath, 'thumbpath:', thumbpath
print 'imagepath[rootlen:]:', imagepath[rootlen:], 'thumbpath[rootlen:]:', thumbpath[rootlen:]
result.append(os.path.join(rootpath, image))
image = image[rootlen:]
item = SubElement(channel, 'item')
title = SubElement(item, 'title')
title.text = image
link = SubElement(item, 'link')
link.text = urllib.quote(imagepath)
description = SubElement(item, 'media:description')
description.text = convert_entities(os.path.splitext(os.path.basename(image))[0])
# need to double quote special characters
thumbnail = SubElement(item, 'media:thumbnail', url=urllib.quote(urllib.quote(thumbpath[rootlen:])))
content = SubElement(item, 'media:content', url=urllib.quote(urllib.quote(imagepath[rootlen:])))
indent(rss)
file = open(os.path.join(root, 'photos.rss'), 'w')
print >>file, '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
print >>file, tostring(rss)
file.close()
return result