当前位置: 首页>>代码示例>>Python>>正文


Python Element.attrib['xmlns:atom']方法代码示例

本文整理汇总了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
开发者ID:adozenlines,项目名称:freevo1,代码行数:48,代码来源:mkimagemrss.py


注:本文中的xml.etree.cElementTree.Element.attrib['xmlns:atom']方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。