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


Python tagsfrompath.TagsFromPattern类代码示例

本文整理汇总了Python中quodlibet.util.tagsfrompath.TagsFromPattern的典型用法代码示例。如果您正苦于以下问题:Python TagsFromPattern类的具体用法?Python TagsFromPattern怎么用?Python TagsFromPattern使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_empty

 def test_empty(self):
     pat = TagsFromPattern('')
     self.assertEquals(pat.match_path(self.f1), self.nomatch)
     self.assertEquals(pat.match_path(self.f2), self.nomatch)
     self.assertEquals(pat.match_path(self.f3), self.nomatch)
     self.assertEquals(pat.match_path(self.b1), self.nomatch)
     self.assertEquals(pat.match_path(self.b2), self.nomatch)
开发者ID:bp0,项目名称:quodlibet,代码行数:7,代码来源:test_util_tagsfrompath.py

示例2: test_nofakes

 def test_nofakes(self):
     pat = TagsFromPattern('<~#track> - <title>')
     self.assertEquals(pat.match_path(self.f1), self.nomatch)
     self.assertEquals(pat.match_path(self.f2), self.nomatch)
     self.assertEquals(pat.match_path(self.f3), self.nomatch)
     self.assertEquals(pat.match_path(self.b1), self.nomatch)
     self.assertEquals(pat.match_path(self.b2), self.nomatch)
开发者ID:bp0,项目名称:quodlibet,代码行数:7,代码来源:test_util_tagsfrompath.py

示例3: test_disctrack

 def test_disctrack(self):
     pat = TagsFromPattern('<discnumber><tracknumber>. <title>')
     self.assertEquals(pat.match_path(fsnative(u'101. T1.ogg')),
         dict(discnumber='1', tracknumber='01', title='T1'))
     self.assertEquals(pat.match_path(fsnative(u'1318. T18.ogg')),
         dict(discnumber='13', tracknumber='18', title='T18'))
     self.assertEquals(pat.match_path(fsnative(u'24. T4.ogg')),
         dict(discnumber='2', tracknumber='4', title='T4'))
开发者ID:bp0,项目名称:quodlibet,代码行数:8,代码来源:test_util_tagsfrompath.py

示例4: test_tracktitle

 def test_tracktitle(self):
     tracktitle = {'tracknumber': '01', 'title': 'Title'}
     btracktitle = {'tracknumber': '01', 'title': 'Artist - Title'}
     pat = TagsFromPattern('<tracknumber> - <title>')
     self.assertEquals(pat.match_path(self.f1), tracktitle)
     self.assertEquals(pat.match_path(self.f2), self.nomatch)
     self.assertEquals(pat.match_path(self.f3), btracktitle)
     self.assertEquals(pat.match_path(self.b1), self.nomatch)
     self.assertEquals(pat.match_path(self.b2), self.nomatch)
开发者ID:bp0,项目名称:quodlibet,代码行数:9,代码来源:test_util_tagsfrompath.py

示例5: test_skip

 def test_skip(self):
     if os.name == "nt":
         pat = TagsFromPattern('<path>\\<~>\\<~>\\<tracknumber> - <title>')
     else:
         pat = TagsFromPattern('<path>/<~>/<~>/<tracknumber> - <title>')
     self.failUnlessEqual(len(pat.headers), 3)
     song = pat.match({"~filename": self.f1})
     self.failUnlessEqual(song.get("path"), "path")
     self.failUnlessEqual(song.get("title"), "Title")
     self.failIf(song.get("album"))
     self.failIf(song.get("artist"))
开发者ID:bp0,项目名称:quodlibet,代码行数:11,代码来源:test_util_tagsfrompath.py

示例6: test_all

 def test_all(self):
     all = {'tracknumber': '01', 'title': 'Title',
            'album': 'Album', 'artist': 'Artist'}
     if os.name == "nt":
         pat = TagsFromPattern('<artist>\\<album>\\<tracknumber> - <title>')
     else:
         pat = TagsFromPattern('<artist>/<album>/<tracknumber> - <title>')
     self.assertEquals(pat.match_path(self.f1), all)
     self.assertEquals(pat.match_path(self.f2), self.nomatch)
     self.assertEquals(pat.match_path(self.f3), self.nomatch)
     self.assertEquals(pat.match_path(self.b1), self.nomatch)
     self.assertEquals(pat.match_path(self.b2), self.nomatch)
开发者ID:bp0,项目名称:quodlibet,代码行数:12,代码来源:test_util_tagsfrompath.py

示例7: test_songtypes

 def test_songtypes(self):
     from quodlibet import formats
     pat = TagsFromPattern('<tracknumber>. <title>')
     tracktitle = {'tracknumber': '01', 'title': 'Title'}
     for ext, kind in formats._infos.iteritems():
         f = formats._audio.AudioFile()
         if not isinstance(kind, type):
             continue
         f.__class__ = kind
         if os.name == "nt":
             f["~filename"] = u'C:\\path\\Artist - Album\\01. Title' + ext
         else:
             f["~filename"] = '/path/Artist - Album/01. Title' + ext
         self.assertEquals(pat.match(f), tracktitle, ext)
开发者ID:bp0,项目名称:quodlibet,代码行数:14,代码来源:test_util_tagsfrompath.py

示例8: __preview

    def __preview(self, songs):
        if songs is None:
            songs = [row[0].song for row in (self.view.get_model() or [])]

        if songs:
            pattern_text = gdecode(self.combo.get_child().get_text())
        else:
            pattern_text = ""
        try:
            pattern = TagsFromPattern(pattern_text)
        except re.error:
            qltk.ErrorMessage(
                self, _("Invalid pattern"),
                _("The pattern\n\t<b>%s</b>\nis invalid. "
                  "Possibly it contains the same tag twice or "
                  "it has unbalanced brackets (&lt; / &gt;).") % (
                util.escape(pattern_text))).run()
            return
        else:
            if pattern_text:
                self.combo.prepend_text(pattern_text)
                self.combo.write(TBP)

        invalid = []

        for header in pattern.headers:
            if not min([song.can_change(header) for song in songs]):
                invalid.append(header)
        if len(invalid) and songs:
            if len(invalid) == 1:
                title = _("Invalid tag")
                msg = _("Invalid tag <b>%s</b>\n\nThe files currently"
                        " selected do not support editing this tag.")
            else:
                title = _("Invalid tags")
                msg = _("Invalid tags <b>%s</b>\n\nThe files currently"
                        " selected do not support editing these tags.")
            qltk.ErrorMessage(
                self, title, msg % ", ".join(invalid)).run()
            pattern = TagsFromPattern("")

        self.view.set_model(None)
        model = ObjectStore()
        for col in self.view.get_columns():
            self.view.remove_column(col)

        render = Gtk.CellRendererText()
        col = TreeViewColumn(title=_('File'))
        col.pack_start(render, True)
        col.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)

        def cell_data_file(column, cell, model, iter_, data):
            entry = model.get_value(iter_)
            cell.set_property("text", entry.name)

        col.set_cell_data_func(render, cell_data_file)

        def cell_data_header(column, cell, model, iter_, header):
            entry = model.get_value(iter_)
            cell.set_property("text", entry.get_match(header))

        self.view.append_column(col)
        for i, header in enumerate(pattern.headers):
            render = Gtk.CellRendererText()
            render.set_property('editable', True)
            render.connect('edited', self.__row_edited, model, header)
            escaped_title = header.replace("_", "__")
            col = Gtk.TreeViewColumn(escaped_title, render)
            col.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
            col.set_cell_data_func(render, cell_data_header, header)
            self.view.append_column(col)

        for song in songs:
            entry = ListEntry(song)
            match = pattern.match(song)
            for h in pattern.headers:
                text = match.get(h, '')
                for f in self.filter_box.filters:
                    if f.active:
                        text = f.filter(h, text)
                if not song.can_multiple_values(h):
                    text = u", ".join(text.split("\n"))
                entry.matches[h] = text
            model.append([entry])

        # save for last to potentially save time
        if songs:
            self.view.set_model(model)
        self.preview.set_sensitive(False)
        self.save.set_sensitive(len(pattern.headers) > 0)
开发者ID:urielz,项目名称:quodlibet,代码行数:90,代码来源:tagsfrompath.py

示例9: test_nongreedy

 def test_nongreedy(self):
     pat = TagsFromPattern('<artist> - <title>')
     dic = pat.match_path(
         fsnative(u"Prefuse 73 - The End of Biters - International.ogg"))
     self.assertEquals(dic["artist"], "Prefuse 73")
     self.assertEquals(dic["title"], "The End of Biters - International")
开发者ID:bp0,项目名称:quodlibet,代码行数:6,代码来源:test_util_tagsfrompath.py

示例10: test_dict

 def test_dict(self):
     tracktitle = {'tracknumber': '01', 'title': 'Title'}
     pat = TagsFromPattern('<tracknumber> - <title>')
     self.assertEquals(pat.match({"~filename": self.f1}), tracktitle)
开发者ID:bp0,项目名称:quodlibet,代码行数:4,代码来源:test_util_tagsfrompath.py


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