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


Python XMLFromMarkupPattern.format方法代码示例

本文整理汇总了Python中quodlibet.pattern.XMLFromMarkupPattern.format方法的典型用法代码示例。如果您正苦于以下问题:Python XMLFromMarkupPattern.format方法的具体用法?Python XMLFromMarkupPattern.format怎么用?Python XMLFromMarkupPattern.format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在quodlibet.pattern.XMLFromMarkupPattern的用法示例。


在下文中一共展示了XMLFromMarkupPattern.format方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_escape

# 需要导入模块: from quodlibet.pattern import XMLFromMarkupPattern [as 别名]
# 或者: from quodlibet.pattern.XMLFromMarkupPattern import format [as 别名]
    def test_escape(s):
        pat = XMLFromMarkupPattern(r'\[b]')
        s.assertEquals(pat.format(s.a), '[b]')
        s._test_markup(pat.format(s.a))

        pat = XMLFromMarkupPattern(r'\\[b]\\[/b]')
        s.assertEquals(pat.format(s.a), r'\<b>\</b>')
        s._test_markup(pat.format(s.a))
开发者ID:SimonLarsen,项目名称:quodlibet,代码行数:10,代码来源:test_pattern.py

示例2: test_span

# 需要导入模块: from quodlibet.pattern import XMLFromMarkupPattern [as 别名]
# 或者: from quodlibet.pattern.XMLFromMarkupPattern import format [as 别名]
    def test_span(s):
        pat = XMLFromMarkupPattern(r'[span]foo[/span]')
        s.assertEquals(pat.format(s.a), '<span>foo</span>')
        s._test_markup(pat.format(s.a))

        pat = XMLFromMarkupPattern(r'[span  weight="bold"]foo[/span]')
        s.assertEquals(pat.format(s.a), '<span  weight="bold">foo</span>')
        s._test_markup(pat.format(s.a))
开发者ID:SimonLarsen,项目名称:quodlibet,代码行数:10,代码来源:test_pattern.py

示例3: test_convenience

# 需要导入模块: from quodlibet.pattern import XMLFromMarkupPattern [as 别名]
# 或者: from quodlibet.pattern.XMLFromMarkupPattern import format [as 别名]
    def test_convenience(s):
        pat = XMLFromMarkupPattern(r'[b]foo[/b]')
        s.assertEquals(pat.format(s.a), '<b>foo</b>')
        s._test_markup(pat.format(s.a))

        pat = XMLFromMarkupPattern('[small ]foo[/small \t]')
        s.assertEquals(pat.format(s.a), '<small >foo</small \t>')
        s._test_markup(pat.format(s.a))
开发者ID:SimonLarsen,项目名称:quodlibet,代码行数:10,代码来源:test_pattern.py

示例4: pattern

# 需要导入模块: from quodlibet.pattern import XMLFromMarkupPattern [as 别名]
# 或者: from quodlibet.pattern.XMLFromMarkupPattern import format [as 别名]
def pattern(pat, cap=True, esc=False, markup=False):
    """Return a 'natural' version of the pattern string for human-readable
    bits. Assumes all tags in the pattern are present.
    """

    from quodlibet.pattern import Pattern, XMLFromPattern, XMLFromMarkupPattern

    class Fakesong(dict):
        cap = False

        def comma(self, key):
            return " - ".join(self.list(key))

        def list(self, key):
            return [tag(k, self.cap) for k in tagsplit(key)]
        list_separate = list

        def __call__(self, tag, *args):
            return 0 if '~#' in tag[:2] else self.comma(tag)

    fakesong = Fakesong({'filename': tag('filename', cap)})
    fakesong.cap = cap
    try:
        if markup:
            p = XMLFromMarkupPattern(pat)
        elif esc:
            p = XMLFromPattern(pat)
        else:
            p = Pattern(pat)
    except ValueError:
        return _("Invalid pattern")

    return p.format(fakesong)
开发者ID:bp0,项目名称:quodlibet,代码行数:35,代码来源:__init__.py

示例5: test_convenience_invalid

# 需要导入模块: from quodlibet.pattern import XMLFromMarkupPattern [as 别名]
# 或者: from quodlibet.pattern.XMLFromMarkupPattern import format [as 别名]
 def test_convenience_invalid(s):
     pat = XMLFromMarkupPattern(r'[b foo="1"]')
     s.assertEquals(pat.format(s.a), '[b foo="1"]')
     s._test_markup(pat.format(s.a))
开发者ID:SimonLarsen,项目名称:quodlibet,代码行数:6,代码来源:test_pattern.py

示例6: test_link

# 需要导入模块: from quodlibet.pattern import XMLFromMarkupPattern [as 别名]
# 或者: from quodlibet.pattern.XMLFromMarkupPattern import format [as 别名]
 def test_link(s):
     pat = XMLFromMarkupPattern(r'[a href=""]foo[/a]')
     s.assertEquals(pat.format(s.a), '<a href="">foo</a>')
开发者ID:SimonLarsen,项目名称:quodlibet,代码行数:5,代码来源:test_pattern.py


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