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

Python utils.filename_to_unicode函数代码示例

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

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



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

示例1: adjustContent

    def adjustContent(self, videoWindow, animate):
        if videoWindow.is_fullscreen:
            self.popInOutButton.setHidden_(YES)
            self.popInOutLabel.setHidden_(YES)
            image_path = resources.path("images/fullscreen_exit.png")
            self.fsButton.setImage_(NSImage.alloc().initWithContentsOfFile_(filename_to_unicode(image_path)))
        else:
            if app.playback_manager.detached_window is None:
                image_path = resources.path("images/popout.png")
                label = _("Pop Out")
            else:
                image_path = resources.path("images/popin.png")
                label = _("Pop In")
            self.popInOutButton.setImage_(NSImage.alloc().initWithContentsOfFile_(filename_to_unicode(image_path)))
            self.popInOutButton.setHidden_(NO)
            self.popInOutLabel.setHidden_(NO)
            self.popInOutLabel.setStringValue_(label)
            image_path = resources.path("images/fullscreen_enter.png")
            self.fsButton.setImage_(NSImage.alloc().initWithContentsOfFile_(filename_to_unicode(image_path)))

        newFrame = self.window().frame()
        if videoWindow.is_fullscreen or app.playback_manager.detached_window is not None:
            self.titleLabel.setHidden_(NO)
            self.feedLabel.setHidden_(NO)
            newFrame.size.height = 198
        else:
            self.titleLabel.setHidden_(YES)
            self.feedLabel.setHidden_(YES)
            newFrame.size.height = 144
        newFrame.origin.x = self.getHorizontalPosition(videoWindow, newFrame.size.width)
        self.window().setFrame_display_animate_(newFrame, YES, animate)
        self.playbackControls.setNeedsDisplay_(YES)
开发者ID:nicolasembleton,项目名称:miro,代码行数:32,代码来源:overlay.py


示例2: awakeFromNib

    def awakeFromNib(self):
        image_path = resources.path('images/subtitles_down.png')
        self.subtitlesButton.setImage_(NSImage.alloc().initWithContentsOfFile_(filename_to_unicode(image_path)))
        self.subtitlesLabel.setTitleWithMnemonic_(_("Subtitles"))
        self.fsLabel.setTitleWithMnemonic_(_("Fullscreen"))
        self.shareButton.setImage_(getOverlayButtonImage(self.shareButton.bounds().size))
        self.shareButton.setAlternateImage_(getOverlayButtonAlternateImage(self.shareButton.bounds().size))
        self.shareButton.setTitle_(_("Share"))

        self.keepButton.setImage_(getOverlayButtonImage(self.keepButton.bounds().size))
        self.keepButton.setAlternateImage_(getOverlayButtonAlternateImage(self.keepButton.bounds().size))
        self.keepButton.setTitle_(_("Keep"))

        self.deleteButton.setImage_(getOverlayButtonImage(self.deleteButton.bounds().size))
        self.deleteButton.setAlternateImage_(getOverlayButtonAlternateImage(self.deleteButton.bounds().size))
        self.deleteButton.setTitle_(_("Delete"))

        self.seekForwardButton.setCell_(SkipSeekButtonCell.cellFromButtonCell_direction_delay_(self.seekForwardButton.cell(), 1, 0.0))
        self.seekForwardButton.cell().setAllowsSkipping(False)
        self.seekBackwardButton.setCell_(SkipSeekButtonCell.cellFromButtonCell_direction_delay_(self.seekBackwardButton.cell(), -1, 0.0))
        self.seekBackwardButton.cell().setAllowsSkipping(False)

        self.progressSlider.cursor = NSImage.imageNamed_(u'fs-progress-slider')
        self.progressSlider.sliderWasClicked = self.progressSliderWasClicked
        self.progressSlider.sliderWasDragged = self.progressSliderWasDragged
        self.progressSlider.sliderWasReleased = self.progressSliderWasReleased
        self.progressSlider.setShowCursor_(True)

        self.volumeSlider.cursor = NSImage.imageNamed_(u'fs-volume-slider')
        self.volumeSlider.sliderWasClicked = self.volumeSliderWasClicked
        self.volumeSlider.sliderWasDragged = self.volumeSliderWasDragged
        self.volumeSlider.sliderWasReleased = self.volumeSliderWasReleased
        self.volumeSlider.setShowCursor_(True)
开发者ID:CodeforEvolution,项目名称:miro,代码行数:33,代码来源:overlay.py


示例3: handle_watched_folder_list

 def handle_watched_folder_list(self, info_list):
     """Handle the WatchedFolderList message."""
     for info in info_list:
         iter = self.model.append(info.id, filename_to_unicode(info.path),
                 info.visible)
         self._iter_map[info.id] = iter
     self.emit('changed')
开发者ID:cool-RR,项目名称:Miro,代码行数:7,代码来源:watchedfolders.py


示例4: _makeSearchIcon

def _makeSearchIcon(engine):
    popupRectangle = NSImage.imageNamed_(u'search_popup_triangle')
    popupRectangleSize = popupRectangle.size()

    engineIconPath = resources.path('images/search_icon_%s.png' % engine.name)
    if not os.path.exists(engineIconPath):
        return nil
    engineIcon = NSImage.alloc().initByReferencingFile_(
      filename_to_unicode(engineIconPath))
    engineIconSize = engineIcon.size()

    searchIconSize = (engineIconSize.width + popupRectangleSize.width + 2, engineIconSize.height)
    searchIcon = NSImage.alloc().initWithSize_(searchIconSize)
    
    searchIcon.lockFocus()
    try:
        engineIcon.drawAtPoint_fromRect_operation_fraction_(
          (0,0), NSZeroRect, NSCompositeSourceOver, 1.0)
        popupRectangleX = engineIconSize.width + 2
        popupRectangleY = (engineIconSize.height - popupRectangleSize.height) / 2
        popupRectangle.drawAtPoint_fromRect_operation_fraction_(
          (popupRectangleX, popupRectangleY), NSZeroRect,
          NSCompositeSourceOver, 1.0)
    finally:
        searchIcon.unlockFocus()

    return searchIcon
开发者ID:CodeforEvolution,项目名称:miro,代码行数:27,代码来源:control.py


示例5: add_device_item

 def add_device_item(self, file_type, path, old_item, metadata_manager):
     """Insert a device_item row for an old item."""
     values = []
     # copy data from old_item so that we don't modify it
     old_data = dict(old_item)
     if path in self.paths_in_metadata_table:
         # This item comes from a 5.x database, so there's data in the
         # metadata tables for it.
         metadata_dict = metadata_manager.get_metadata(path)
         for key, value in metadata_dict.items():
             old_data[key] = value
     for name, field in schema.DeviceItemSchema.fields:
         # get value from the old item
         if name == 'id':
             value = self.id_counter.next()
         elif name == 'filename':
             value = filename_to_unicode(path)
         elif name == 'file_type':
             value = file_type
         elif name == 'net_lookup_enabled':
             value = False
         else:
             value = old_data.get(name)
         # convert value
         if value is not None:
             if isinstance(field, schema.SchemaDateTime):
                 value = datetime.datetime.fromtimestamp(value)
         values.append(value)
     self.cursor.execute(self.device_item_insert_sql, values)
开发者ID:CodeforEvolution,项目名称:miro,代码行数:29,代码来源:devicedatabaseupgrade.py


示例6: item_matches

def item_matches(item, search_text):
    """Test if a single ItemInfo matches a search

    :param item: Item to test
    :param search_text: search_text to search with

    :returns: True if the item matches the search string
    """
    parsed_search = _get_boolean_search(search_text)

    match_against = [item.title, item.description, item.entry_description]
    match_against.append(item.artist)
    match_against.append(item.album)
    match_against.append(item.genre)
    match_against.append(item.get_source_for_search())
    if item.filename:
        filename = os.path.basename(item.filename)
        match_against.append(filename_to_unicode(filename))
    match_against_text = " ".join(term.lower() for term in match_against if term is not None)

    for term in parsed_search.positive_terms:
        if term not in match_against_text:
            return False
    for term in parsed_search.negative_terms:
        if term in match_against_text:
            return False
    return True
开发者ID:ktan2020,项目名称:miro,代码行数:27,代码来源:search.py


示例7: _convert_status_to_sql

 def _convert_status_to_sql(self, status_dict):
     to_save = status_dict.copy()
     filename_fields = schema.SchemaStatusContainer.filename_fields
     for key in filename_fields:
         value = to_save.get(key)
         if value is not None:
             to_save[key] = filename_to_unicode(value)
     return repr(to_save)
开发者ID:kmshi,项目名称:miro,代码行数:8,代码来源:storedatabase.py


示例8: init

 def init(self):
     self = super(MiroSearchTextField, self).init()
     imagepath = filename_to_unicode(
                 resources.path('images/search_icon_all.png'))
     image = NSImage.alloc().initByReferencingFile_(imagepath)
     self.cell().searchButtonCell().setImage_(image)
     self.cell().searchButtonCell().setAlternateImage_(image)
     return self
开发者ID:CodeforEvolution,项目名称:miro,代码行数:8,代码来源:control.py


示例9: _item_exists_for_path

def _item_exists_for_path(path):
    # in SQLite, LIKE is case insensitive, so we can use it to only look at
    # filenames that possibly will match
    for item_ in item.Item.make_view('filename LIKE ?',
            (filename_to_unicode(path),)):
        if samefile(item_.filename, path):
            return item_
    return False
开发者ID:nxmirrors,项目名称:miro,代码行数:8,代码来源:commandline.py


示例10: item_matches_search

def item_matches_search(item_info, search_text):
    """Check if an item matches search text."""
    if search_text == '':
        return True
    match_against = [item_info.name, item_info.description]
    if item_info.video_path is not None:
        match_against.append(filename_to_unicode(item_info.video_path))
    return search.match(search_text, match_against)
开发者ID:cool-RR,项目名称:Miro,代码行数:8,代码来源:itemlist.py


示例11: __init__

 def __init__(self, path):
     Widget.__init__(self)
     self.nsimage = NSImage.alloc().initByReferencingFile_(
       filename_to_unicode(path))
     self.view = MiroImageView.alloc().init()
     self.view.setImage_(self.nsimage)
     # enabled when viewWillMoveToWindow:aWindow invoked
     self.view.setAnimates_(NO)
开发者ID:CodeforEvolution,项目名称:miro,代码行数:8,代码来源:simple.py


示例12: to_dict

 def to_dict(self):
     data = {}
     for k, v in self.__dict__.items():
         if v is not None and k not in (u'device', u'file_type', u'id',
                                        u'video_path', u'_deferred_update'):
             if ((k == u'screenshot' or k == u'cover_art')):
                 v = filename_to_unicode(v)
             data[k] = v
     return data
开发者ID:kmshi,项目名称:miro,代码行数:9,代码来源:devices.py


示例13: handle_change_clicked

 def handle_change_clicked(widget):
     dir_ = dialogs.ask_for_directory(
         _("Choose directory to search for media files"),
         initial_directory=_get_user_media_directory(),
         transient_for=self)
     if dir_:
         search_entry.set_text(filename_to_unicode(dir_))
         self.search_directory = dir_
     else:
         self.search_directory = _get_user_media_directory()
开发者ID:cool-RR,项目名称:Miro,代码行数:10,代码来源:firsttimedialog.py


示例14: handle_watched_folders_changed

 def handle_watched_folders_changed(self, added, changed, removed):
     """Handle the WatchedFoldersChanged message."""
     self.handle_watched_folder_list(added)
     for info in changed:
         iter = self._iter_map[info.id]
         self.model.update_value(iter, 1, filename_to_unicode(info.path))
         self.model.update_value(iter, 2, info.visible)
     for id in removed:
         iter = self._iter_map.pop(id)
         self.model.remove(iter)
     self.emit('changed')
开发者ID:cool-RR,项目名称:Miro,代码行数:11,代码来源:watchedfolders.py


示例15: handle_change_clicked

 def handle_change_clicked(widget):
     dir_ = dialogs.ask_for_directory(
         _("Choose directory to search for media files"),
         initial_directory=get_default_search_dir(),
         transient_for=self)
     if dir_:
         search_entry.set_text(filename_to_unicode(dir_))
         self.search_directory = dir_
     else:
         self.search_directory = get_default_search_dir()
     # reset the search results if they change the directory
     self.gathered_media_files = None
开发者ID:codito,项目名称:miro,代码行数:12,代码来源:firsttimedialog.py


示例16: test_goodfile

    def test_goodfile(self):
        # Our file templates.  Try a vanilla version and one with escapes,
        # and a path for Windows.
        path1 = "/Users/xxx/Music/iTunes/iTunes%20Music/"
        path2 = ("/Volumes/%E3%83%9B%E3%83%BC%E3%83%A0/"
                 "xxx/Music/iTunes/iTunes%20Media/")
        path3 = ("C:/Documents%20and%20Settings/Paul/"
                 "My%20Documents/My%20Music/iTunes/iTunes%20Media/")
        file_snippet1 = file_template % dict(path=(self.file_url + path1))
        file_snippet2 = file_template % dict(path=(self.file_url + path2))
        file_snippet3 = file_template % dict(path=(self.file_url + path3))

        tmpf_dir = os.path.dirname(self.tmpf_path)
        # Test vanilla path
        self._clean_tmpf()
        self.tmpf.write(file_snippet1)
        self.tmpf.flush()
        path = import_itunes_path(tmpf_dir)
        self.assertEquals(type(path), unicode)
        self.assertEquals(path, filename_to_unicode(
                urllib.url2pathname(path1)))

        # Test path with utf-8 escapes
        self._clean_tmpf()
        self.tmpf.write(file_snippet2)
        self.tmpf.flush()
        path = import_itunes_path(tmpf_dir)
        self.assertEquals(type(path), unicode)
        self.assertEquals(path, filename_to_unicode(
                urllib.url2pathname(path2)))

        # Test Windows path
        self._clean_tmpf()
        self.tmpf.write(file_snippet3)
        self.tmpf.flush()
        path = import_itunes_path(tmpf_dir)
        self.assertEquals(type(path), unicode)
        self.assertEquals(path, filename_to_unicode(
                urllib.url2pathname(path3)))
开发者ID:CodeforEvolution,项目名称:miro,代码行数:39,代码来源:importtest.py


示例17: _calc_search_text

def _calc_search_text(item_info):
    match_against = [ item_info.name, item_info.description ]
    match_against.append(item_info.artist)
    match_against.append(item_info.album)
    match_against.append(item_info.genre)
    if item_info.feed_name is not None:
        match_against.append(item_info.feed_name)
    if item_info.download_info and item_info.download_info.torrent:
        match_against.append(u'torrent')
    if item_info.video_path:
        filename = os.path.basename(item_info.video_path)
        match_against.append(filename_to_unicode(filename))
    return (' '.join(match_against)).lower()
开发者ID:nxmirrors,项目名称:miro,代码行数:13,代码来源:search.py


示例18: _getEngineIcon

def _getEngineIcon(engine):
    engineIconPath = resources.path('images/search_icon_%s.png' % engine.name)
    if app.config.get(prefs.THEME_NAME) and engine.filename:
        if engine.filename.startswith(resources.theme_path(
            app.config.get(prefs.THEME_NAME), 'searchengines')):
                # this search engine came from a theme; look up the icon in the
                # theme directory instead
                engineIconPath = resources.theme_path(
                    app.config.get(prefs.THEME_NAME),
                    'images/search_icon_%s.png' % engine.name)
    if not os.path.exists(engineIconPath):
        return nil
    return NSImage.alloc().initByReferencingFile_(
      filename_to_unicode(engineIconPath))
开发者ID:CodeforEvolution,项目名称:miro,代码行数:14,代码来源:control.py


示例19: run_dialog

    def run_dialog(self):
        """
        Returns (directory, show-in-sidebar) or None
        """
        try:
            extra = widgetset.VBox(spacing=10)
            if self.previous_error:
                extra.pack_start(widgetset.Label(self.previous_error))

            self.folder_entry = widgetset.TextEntry()
            self.folder_entry.set_activates_default(True)
            self.folder_entry.set_text(filename_to_unicode(self.path))
            self.folder_entry.set_size_request(300, -1)

            choose_button = widgetset.Button(_("Choose..."))
            choose_button.connect('clicked', self.handle_choose)

            h = widgetset.HBox(spacing=5)
            h.pack_start(widgetutil.align_middle(
                widgetset.Label(_("Directory:"))))
            h.pack_start(widgetutil.align_middle(self.folder_entry))
            h.pack_start(widgetutil.align_middle(choose_button))

            extra.pack_start(h)

            self.visible_checkbox = widgetset.Checkbox(
                _("Show in my sidebar as a podcast"))
            self.visible_checkbox.set_checked(True)
            extra.pack_start(self.visible_checkbox)

            self.vbox = extra

            self.set_extra_widget(extra)
            self.add_button(BUTTON_ADD_FOLDER.text)
            self.add_button(BUTTON_CANCEL.text)

            ret = self.run()
            if ret == 0:
                # 17407 band-aid - don't init with PlatformFilenameType since
                # str use ascii codec
                dir = self.folder_entry.get_text()
                if PlatformFilenameType == str:
                    dir = dir.encode('utf-8')
                return (dir, self.visible_checkbox.get_checked())

            return None

        except StandardError:
            logging.exception("newwatchedfolder threw exception.")
开发者ID:CodeforEvolution,项目名称:miro,代码行数:49,代码来源:newwatchedfolder.py


示例20: export_content

    def export_content(self, pathname, media_tabs, site_tabs):
        """Given a pathname (which is just written into the opml), a
        list of media_tabs, and a list of site_tabs, generates the
        OPML and returns it as a utf-8 encoded string.
        """
        self.io = StringIO()
        self.current_folder = None

        now = datetime.now()

        self.io.write(u'<?xml version="1.0" encoding="utf-8" ?>\n')
        self.io.write(u'<!-- OPML generated by Miro v%s on %s -->\n' % (
            app.config.get(prefs.APP_VERSION), now.ctime()))
        self.io.write(u'<opml version="2.0"\n')
        self.io.write(u' xmlns:miro="http://getmiro.com/opml/subscriptions">\n')
        self.io.write(u'<head>\n')
        self.io.write(u'\t<title>%s</title>\n' % (
            filename_to_unicode(os.path.basename(pathname))))
        self.io.write(u'\t<dateCreated>%s</dateCreated>\n' % now.ctime())
        self.io.write(u'\t<docs>http://www.opml.org/spec2</docs>\n')
        self.io.write(u'</head>\n')
        self.io.write(u'<body>\n')

        for obj in media_tabs:
            if isinstance(obj, folder.ChannelFolder):
                self._open_folder_entry(obj)
            elif isinstance(obj, feed.Feed):
                self._write_feed_entry(obj)

        if self.current_folder is not None:
            self._close_folder_entry()

        for obj in site_tabs:
            self._write_site_entry(obj)

        self.io.write(u'</body>\n')
        self.io.write(u'</opml>\n')

        try:
            outstring = self.io.getvalue().encode("utf-8")
        except UnicodeError:
            logging.exception("Could not encode unicode to utf-8.")
            return u""
        return outstring
开发者ID:cool-RR,项目名称:Miro,代码行数:44,代码来源:opml.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.unicode_to_filename函数代码示例发布时间:2022-05-27
下一篇:
Python resources.path函数代码示例发布时间: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