當前位置: 首頁>>代碼示例>>Python>>正文


Python pattern.XMLFromMarkupPattern類代碼示例

本文整理匯總了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)
開發者ID:bp0,項目名稱:quodlibet,代碼行數:33,代碼來源:__init__.py

示例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))
開發者ID:SimonLarsen,項目名稱:quodlibet,代碼行數:8,代碼來源:test_pattern.py

示例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))
開發者ID:SimonLarsen,項目名稱:quodlibet,代碼行數:8,代碼來源:test_pattern.py

示例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))
開發者ID:SimonLarsen,項目名稱:quodlibet,代碼行數:8,代碼來源:test_pattern.py

示例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))
開發者ID:SimonLarsen,項目名稱:quodlibet,代碼行數:4,代碼來源:test_pattern.py

示例6: test_link

 def test_link(s):
     pat = XMLFromMarkupPattern(r'[a href=""]foo[/a]')
     s.assertEquals(pat.format(s.a), '<a href="">foo</a>')
開發者ID:SimonLarsen,項目名稱:quodlibet,代碼行數:3,代碼來源:test_pattern.py


注:本文中的quodlibet.pattern.XMLFromMarkupPattern類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。