本文整理汇总了Python中quodlibet.pattern.XMLFromMarkupPattern类的典型用法代码示例。如果您正苦于以下问题:Python XMLFromMarkupPattern类的具体用法?Python XMLFromMarkupPattern怎么用?Python XMLFromMarkupPattern使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XMLFromMarkupPattern类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pattern
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)
示例2: test_escape
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))
示例3: test_span
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))
示例4: test_convenience
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))
示例5: test_convenience_invalid
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))
示例6: test_link
def test_link(s):
pat = XMLFromMarkupPattern(r'[a href=""]foo[/a]')
s.assertEquals(pat.format(s.a), '<a href="">foo</a>')