• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.name_sort_key函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_hashable

 def test_hashable(self):
     for testcase in (None,
                      u'',
                      u'a',
                      u'a1a',
                      u'Episode_100',
                      u'episode_1',
                      ):
         hash(util.name_sort_key(testcase))
开发者ID:foxi,项目名称:miro,代码行数:9,代码来源:utiltest.py


示例2: test_simple

 def test_simple(self):
     for testcase in ((None, 'ZZZZZZZZZZZZZ'),
                      (u'', [u'']),
                      (u'a', [u'a']),
                      (u'a1a', [u'a', 1.0, u'a']),
                      (u'Episode_100', [u'episode_', 100.0, u'']),
                      (u'episode_1', [u'episode_', 1.0, u''])
                      ):
         self.assertEquals(util.name_sort_key(testcase[0]),
                           testcase[1])
开发者ID:codito,项目名称:miro,代码行数:10,代码来源:utiltest.py


示例3: test_name_sort

 def test_name_sort(self):
     # Test that name sort does a natural sort on the items, and removes
     # "the" / "a" from the begining
     self.items[0].title = u'Podcast Item A'
     self.items[1].title = u'The Podcast Item B'
     self.items[2].title = u'A Podcast Item C'
     self.items[3].title = u'SeriesItem9'
     self.items[4].title = u'SeriesItem10'
     self.items[5].title = u'SeriesItem11'
     for i in self.items[:6]:
         i.signal_change()
     app.db.finish_transaction()
     # test that the default sort is release date
     self.item_list.set_sort(itemsort.TitleSort(True))
     self.items.sort(key=lambda i: util.name_sort_key(i.title))
     self.check_sort_order(self.items)
开发者ID:dankamongmen,项目名称:miro,代码行数:16,代码来源:itemlisttest.py


示例4: album_artist_sort_key

 def album_artist_sort_key(self):
     if self.album_artist:
         return util.name_sort_key(self.album_artist)
     else:
         return self.artist_sort_key
开发者ID:dankamongmen,项目名称:miro,代码行数:5,代码来源:item.py


示例5: album_sort_key

 def album_sort_key(self):
     return util.name_sort_key(self.album)
开发者ID:dankamongmen,项目名称:miro,代码行数:2,代码来源:item.py


示例6: artist_sort_key

 def artist_sort_key(self):
     return util.name_sort_key(self.artist)
开发者ID:dankamongmen,项目名称:miro,代码行数:2,代码来源:item.py


示例7: title_sort_key

 def title_sort_key(self):
     return util.name_sort_key(self.title)
开发者ID:dankamongmen,项目名称:miro,代码行数:2,代码来源:item.py


示例8: sort_key

 def sort_key(self, item):
     return [int(item.track),
             util.name_sort_key(item.artist),
             util.name_sort_key(item.album)]
开发者ID:cool-RR,项目名称:Miro,代码行数:4,代码来源:itemlist.py


示例9: get_channel_info

 def get_channel_info(self):
     self.channels = [ci for ci in app.tabs['feed'].get_feeds()
             if not (ci.is_folder or ci.is_directory_feed)]
     self.channels.sort(key=lambda x: util.name_sort_key(x.name))
开发者ID:CodeforEvolution,项目名称:miro,代码行数:4,代码来源:newsearchfeed.py


示例10: run_dialog

def run_dialog():
    """Creates and launches the Add to Playlist dialog.  This dialog
    waits for the user to press "Add" or "Cancel".

    In the case of "Add", returns a tuple of:

    * ("new", playlist_name)
    * ("existing", playlist id)

    In the case of "Cancel", returns None.
    """
    title = _('Add a Playlist')
    description = _('Add items to an existing playlist or a new one.')

    playlists = app.tab_list_manager.playlist_list.get_playlists()
    playlists = [pi for pi in playlists if not pi.is_folder]
    playlists.sort(key=lambda x: name_sort_key(x.name))

    window = MainDialog(title, description)
    try:
        try:
            window.add_button(BUTTON_ADD.text)
            window.add_button(BUTTON_CANCEL.text)

            extra = widgetset.VBox()

            choice_table = widgetset.Table(columns=2, rows=2)
            choice_table.set_column_spacing(5)
            choice_table.set_row_spacing(5)
            rbg = widgetset.RadioButtonGroup()

            existing_rb = widgetset.RadioButton(_("Existing playlist:"), rbg)
            existing_option = widgetset.OptionMenu([clamp_text(pi.name) for pi in playlists])

            choice_table.pack(existing_rb, 0, 0)
            choice_table.pack(existing_option, 1, 0)

            new_rb = widgetset.RadioButton(_("New playlist:"), rbg)
            new_text = widgetset.TextEntry()
            new_text.set_activates_default(True)
            choice_table.pack(new_rb, 0, 1)
            choice_table.pack(new_text, 1, 1)

            # only the existing row is enabled
            choice_table.disable(row=1, column=1)

            def handle_clicked(widget):
                # this enables and disables the fields in the table
                # based on which radio button is selected
                if widget is existing_rb:
                    choice_table.enable(row=0, column=1)
                    choice_table.disable(row=1, column=1)
                else:
                    choice_table.disable(row=0, column=1)
                    choice_table.enable(row=1, column=1)
                if new_rb.get_selected():
                    new_text.focus()

            existing_rb.connect('clicked', handle_clicked)
            new_rb.connect('clicked', handle_clicked)

            extra.pack_start(widgetutil.align_top(choice_table, top_pad=6))

            window.set_extra_widget(extra)
            response = window.run()

            if response == 0:
                selected_option = rbg.get_selected()
                if selected_option is existing_rb and len(playlists) > 0:
                    return ("existing", playlists[existing_option.get_selected()])
                elif new_text.get_text():
                    return ("new", new_text.get_text())
        except StandardError:
            logging.exception("addtoplaylistdialog threw exception.")
    finally:
        window.destroy()
开发者ID:nxmirrors,项目名称:miro,代码行数:76,代码来源:addtoplaylistdialog.py


示例11: run_dialog

def run_dialog():
    """Creates and launches the New Search Feed dialog.  This dialog waits
    for the user to press "Create Feed" or "Cancel".

    In the case of "Create Feed", returns a tuple of:

    * ("feed", ChannelInfo, search_term str, section str)
    * ("search_engine", SearchEngineInfo, search_term str, section str)
    * ("url", url str, search_term str, section str)

    In the case of "Cancel", returns None.
    """
    title = _('New Search Feed')
    description = _('A search feed contains items that match a search term.')

    channels = app.tab_list_manager.feed_list.get_feeds()
    channels += app.tab_list_manager.audio_feed_list.get_feeds()
    channels = [ci for ci in channels if not ci.is_folder]
    channels.sort(key=lambda x: util.name_sort_key(x.name))

    window = MainDialog(title, description)
    try:
        try:
            window.add_button(BUTTON_CREATE_FEED.text)
            window.add_button(BUTTON_CANCEL.text)

            extra = widgetset.VBox()

            hb1 = widgetset.HBox()
            hb1.pack_start(widgetset.Label(_('Search for:')), padding=5)
            searchterm = widgetset.TextEntry()
            searchterm.set_activates_default(True)
            hb1.pack_start(searchterm, expand=True)
            extra.pack_start(hb1)

            hb2 = widgetset.HBox()
            hb2.pack_start(widgetutil.align_top(widgetset.Label(_('In this:')), top_pad=3), padding=5)

            choice_table = widgetset.Table(columns=2, rows=3)
            choice_table.set_column_spacing(5)
            choice_table.set_row_spacing(5)
            rbg = widgetset.RadioButtonGroup()

            channel_rb = widgetset.RadioButton(_("Feed:"), rbg)
            channel_option = widgetset.OptionMenu(
                [ci.name + u" - " + ci.url for ci in channels])
            channel_option.set_size_request(250, -1)
            choice_table.pack(channel_rb, 0, 0)
            choice_table.pack(channel_option, 1, 0)

            search_engine_rb = widgetset.RadioButton(_("Search engine:"), rbg)
            search_engines = searchengines.get_search_engines()
            search_engine_option = widgetset.OptionMenu([se.title for se in search_engines])
            choice_table.pack(search_engine_rb, 0, 1)
            choice_table.pack(search_engine_option, 1, 1)

            url_rb = widgetset.RadioButton(_("URL:"), rbg)
            url_text = widgetset.TextEntry()
            choice_table.pack(url_rb, 0, 2)
            choice_table.pack(url_text, 1, 2)

            hb2.pack_start(choice_table, expand=True)

            # only the channel row is enabled
            choice_table.disable(row=1, column=1)
            choice_table.disable(row=2, column=1)

            def handle_clicked(widget):
                # this enables and disables the fields in the table
                # based on which radio button is selected
                if widget is channel_rb:
                    choice_table.enable(row=0, column=1)
                    choice_table.disable(row=1, column=1)
                    choice_table.disable(row=2, column=1)
                elif widget is search_engine_rb:
                    choice_table.disable(row=0, column=1)
                    choice_table.enable(row=1, column=1)
                    choice_table.disable(row=2, column=1)
                else:
                    choice_table.disable(row=0, column=1)
                    choice_table.disable(row=1, column=1)
                    choice_table.enable(row=2, column=1)

            channel_rb.connect('clicked', handle_clicked)
            search_engine_rb.connect('clicked', handle_clicked)
            url_rb.connect('clicked', handle_clicked)

            extra.pack_start(widgetutil.align_top(hb2, top_pad=6))

            hb3 = widgetset.HBox()
            hb3.pack_start(widgetutil.align_top(widgetset.Label(_('Add new feed to this section:')), top_pad=3), padding=5)

            rbg_section = widgetset.RadioButtonGroup()
            video_rb = widgetset.RadioButton(_("video"), rbg_section)
            audio_rb = widgetset.RadioButton(_("audio"), rbg_section)
            hb3.pack_start(video_rb)
            hb3.pack_start(audio_rb)
            extra.pack_start(widgetutil.align_top(hb3, top_pad=6))

            window.set_extra_widget(extra)
#.........这里部分代码省略.........
开发者ID:cool-RR,项目名称:Miro,代码行数:101,代码来源:newsearchfeed.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python component.get函数代码示例发布时间:2022-05-27
下一篇:
Python util.gather_subtitle_files函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap