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


Python senf.fsn2uri函数代码示例

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


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

示例1: get_example_xml

def get_example_xml(song_path, rating, lastplayed):

    song_uri = fsn2uri(song_path)
    mount_uri = fsn2uri(find_mount_point(song_path))

    return (u"""\
<?xml version="1.0" standalone="yes"?>
<rhythmdb version="1.9">
  <entry type="song">
    <title>Music</title>
    <genre>Unknown</genre>
    <track-number>7</track-number>
    <duration>199</duration>
    <file-size>4799124</file-size>
    <location>%s</location>
    <mountpoint>%s</mountpoint>
    <mtime>1378717158</mtime>
    <first-seen>1339576187</first-seen>
    <last-seen>1409855394</last-seen>
    <last-played>%d</last-played>
    <play-count>1</play-count>
    <bitrate>191</bitrate>
    <rating>%d</rating>
    <date>731881</date>
    <media-type>audio/mpeg</media-type>
    <composer>Unknown</composer>
  </entry>
</rhythmdb>\
""" % (song_uri, mount_uri, lastplayed, rating)).encode("utf-8")
开发者ID:LudoBike,项目名称:quodlibet,代码行数:29,代码来源:test_rbimport.py

示例2: test_fsn2uri

 def test_fsn2uri(self):
     if os.name != "nt":
         uri = fsn2uri(fsnative(u"/öäü.txt"))
         self.assertEqual(uri, u"file:///%C3%B6%C3%A4%C3%BC.txt")
     else:
         uri = fsn2uri(fsnative(u"C:\\öäü.txt"))
         self.assertEqual(
             uri, "file:///C:/%C3%B6%C3%A4%C3%BC.txt")
         self.assertEqual(
             fsn2uri(u"C:\\SomeDir\xe4"), "file:///C:/SomeDir%C3%A4")
开发者ID:faubiguy,项目名称:quodlibet,代码行数:10,代码来源:test_util_path.py

示例3: test_thumb

    def test_thumb(s):
        thumb = thumbnails.get_thumbnail(s.filename, (50, 60))

        #check for right scaling
        s.failUnless(thumb)
        s.failUnlessEqual((thumb.get_width(), thumb.get_height()), (50, 25))

        #test the thumbnail filename
        uri = fsn2uri(s.filename)
        name = hash.md5(uri.encode("ascii")).hexdigest() + ".png"

        path = thumbnails.get_thumbnail_folder()
        path = os.path.join(path, "normal", name)

        s.failUnless(os.path.isfile(path))

        #check for metadata
        thumb_pb = GdkPixbuf.Pixbuf.new_from_file(path)
        meta_mtime = thumb_pb.get_option("tEXt::Thumb::MTime")
        meta_uri = thumb_pb.get_option("tEXt::Thumb::URI")

        s.failUnlessEqual(int(meta_mtime), int(mtime(s.filename)))
        s.failUnlessEqual(meta_uri, uri)

        #check rights
        if os.name != "nt":
            s.failUnlessEqual(os.stat(path).st_mode, 33152)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:27,代码来源:test_util_thumbnails.py

示例4: get_cache_info

def get_cache_info(path, boundary):
    """For an image at `path` return (cache_path, thumb_size)

    cache_path points to a potential cache file
    thumb size is either 128 or 256
    """

    assert isinstance(path, fsnative)

    width, height = boundary

    if width <= ThumbSize.NORMAL and height <= ThumbSize.NORMAL:
        size_name = "normal"
        thumb_size = ThumbSize.NORMAL
    else:
        size_name = "large"
        thumb_size = ThumbSize.LARGE

    thumb_folder = get_thumbnail_folder()
    cache_dir = os.path.join(thumb_folder, size_name)

    uri = fsn2uri(path)
    thumb_name = hashlib.md5(uri).hexdigest() + ".png"
    thumb_path = os.path.join(cache_dir, thumb_name)

    return (thumb_path, thumb_size)
开发者ID:urielz,项目名称:quodlibet,代码行数:26,代码来源:thumbnails.py

示例5: _show_files_thunar

def _show_files_thunar(dirname, entries):
    # https://git.xfce.org/xfce/thunar/tree/thunar/thunar-dbus-service-infos.xml
    XFCE_PATH = "/org/xfce/FileManager"
    XFCE_NAME = "org.xfce.FileManager"
    XFCE_IFACE = "org.xfce.FileManager"

    try:
        dbus_proxy = _get_dbus_proxy(XFCE_NAME, XFCE_PATH, XFCE_IFACE)

        if not entries:
            dbus_proxy.DisplayFolder('(sss)',
                                     fsn2uri(dirname), "", _get_startup_id())
        else:
            dbus_proxy.DisplayFolderAndSelect(
                '(ssss)', fsn2uri(dirname), entries[0], "", _get_startup_id())
    except GLib.Error as e:
        raise BrowseError(e)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:17,代码来源:showfiles.py

示例6: _get_image_uri

    def _get_image_uri(self, song):
        """A unicode file URI or an empty string"""

        fileobj = app.cover_manager.get_cover(song)
        self._set_image_fileobj(fileobj)
        if fileobj:
            return fsn2uri(fileobj.name)
        return u""
开发者ID:Muges,项目名称:quodlibet,代码行数:8,代码来源:notify.py

示例7: _show_files_fdo

def _show_files_fdo(dirname, entries):
    # https://www.freedesktop.org/wiki/Specifications/file-manager-interface/
    FDO_PATH = "/org/freedesktop/FileManager1"
    FDO_NAME = "org.freedesktop.FileManager1"
    FDO_IFACE = "org.freedesktop.FileManager1"

    try:
        dbus_proxy = _get_dbus_proxy(FDO_NAME, FDO_PATH, FDO_IFACE)

        if not entries:
            dbus_proxy.ShowFolders('(ass)',
                                   [fsn2uri(dirname)], _get_startup_id())
        else:
            item_uri = fsn2uri(os.path.join(dirname, entries[0]))
            dbus_proxy.ShowItems('(ass)', [item_uri], _get_startup_id())
    except GLib.Error as e:
        raise BrowseError(e)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:17,代码来源:showfiles.py

示例8: test_roundtrip

    def test_roundtrip(self):
        if os.name == "nt":
            paths = [u"C:\\öäü.txt"]
        else:
            paths = [u"/öäü.txt", u"//foo/bar", u"///foo/bar"]

        for source in paths:
            path = uri2fsn(fsn2uri(fsnative(source)))
            self.assertTrue(is_fsnative(path))
            self.assertEqual(path, fsnative(source))
开发者ID:faubiguy,项目名称:quodlibet,代码行数:10,代码来源:test_util_path.py

示例9: label_path

        def label_path(path):
            l = Gtk.Label(label="<a href='%s'>%s</a>" % (
                            fsn2uri(path), escape(fsn2text(unexpand(path)))),
                          use_markup=True,
                          ellipsize=Pango.EllipsizeMode.MIDDLE,
                          xalign=0,
                          selectable=True)

            l.connect("activate-link", show_uri)
            return l
开发者ID:LudoBike,项目名称:quodlibet,代码行数:10,代码来源:appinfo.py

示例10: _show_files_fdo

def _show_files_fdo(dirname, entries):
    # http://www.freedesktop.org/wiki/Specifications/file-manager-interface
    FDO_PATH = "/org/freedesktop/FileManager1"
    FDO_NAME = "org.freedesktop.FileManager1"
    FDO_IFACE = "org.freedesktop.FileManager1"

    if not dbus:
        raise BrowseError("no dbus")

    try:
        bus = dbus.SessionBus()
        bus_object = bus.get_object(FDO_NAME, FDO_PATH)
        bus_iface = dbus.Interface(bus_object, dbus_interface=FDO_IFACE)

        if not entries:
            bus_iface.ShowFolders([fsn2uri(dirname)], _get_startup_id())
        else:
            item_uri = fsn2uri(os.path.join(dirname, entries[0]))
            bus_iface.ShowItems([item_uri], _get_startup_id())
    except dbus.DBusException as e:
        raise BrowseError(e)
开发者ID:Muges,项目名称:quodlibet,代码行数:21,代码来源:showfiles.py

示例11: test_parse_onesong_uri

 def test_parse_onesong_uri(self):
     target = get_data_path("silence-44-s.ogg")
     target = fsn2uri(target).encode("ascii")
     target = self.prefix + target
     with temp_filename() as name:
         with open(name, "wb") as f:
             f.write(target)
         with open(name, "rb") as f:
             pl = self.Parse(f, name)
     self.failUnlessEqual(len(pl), 1)
     self.failUnlessEqual(pl[0]("title"), "Silence")
     pl.delete()
开发者ID:LudoBike,项目名称:quodlibet,代码行数:12,代码来源:test_browsers_playlists.py

示例12: _show_files_thunar

def _show_files_thunar(dirname, entries):
    # http://git.xfce.org/xfce/thunar/tree/thunar/thunar-dbus-service-infos.xml
    XFCE_PATH = "/org/xfce/FileManager"
    XFCE_NAME = "org.xfce.FileManager"
    XFCE_IFACE = "org.xfce.FileManager"

    if not dbus:
        raise BrowseError("no dbus")

    try:
        bus = dbus.SessionBus()
        bus_object = bus.get_object(XFCE_NAME, XFCE_PATH)
        bus_iface = dbus.Interface(bus_object, dbus_interface=XFCE_IFACE)

        if not entries:
            bus_iface.DisplayFolder(fsn2uri(dirname), "", _get_startup_id())
        else:
            item_name = os.path.join(dirname, entries[0])
            bus_iface.DisplayFolderAndSelect(
                fsn2uri(dirname), item_name, "", _get_startup_id())
    except dbus.DBusException as e:
        raise BrowseError(e)
开发者ID:Muges,项目名称:quodlibet,代码行数:22,代码来源:showfiles.py

示例13: test_parse_onesong_uri

 def test_parse_onesong_uri(self):
     h, name = mkstemp()
     os.close(h)
     target = get_data_path("silence-44-s.ogg")
     target = fsn2uri(target)
     target = self.prefix + target
     with open(name, "w") as f:
         f.write(target)
     list = self.Parse(name)
     os.unlink(name)
     self.failUnlessEqual(len(list), 1)
     self.failUnlessEqual(list[0]("title"), "Silence")
     list.delete()
开发者ID:urielz,项目名称:quodlibet,代码行数:13,代码来源:test_browsers_playlists.py

示例14: get_property

 def get_property(self, interface, name):
     if interface == MediaObject.IFACE:
         if name == "Parent":
             return EntryObject.PATH
         elif name == "Type":
             return "image"
         elif name == "Path":
             return Icon.PATH
         elif name == "DisplayName":
             return "I'm an icon \o/"
     elif interface == MediaItem.IFACE:
         if name == "URLs":
             return [fsn2uri(self.__f.name)]
         elif name == "MIMEType":
             return "image/png"
         elif name == "Width" or name == "Height":
             return Icon.SIZE
         elif name == "ColorDepth":
             return self.__depth
开发者ID:urielz,项目名称:quodlibet,代码行数:19,代码来源:mediaserver.py

示例15: browse_folders_thunar

def browse_folders_thunar(songs, display=""):
    # http://git.xfce.org/xfce/thunar/tree/thunar/thunar-dbus-service-infos.xml
    XFCE_PATH = "/org/xfce/FileManager"
    XFCE_NAME = "org.xfce.FileManager"
    XFCE_IFACE = "org.xfce.FileManager"

    if not dbus:
        raise BrowseError("no dbus")

    try:
        bus = dbus.SessionBus()
        bus_object = bus.get_object(XFCE_NAME, XFCE_PATH)
        bus_iface = dbus.Interface(bus_object, dbus_interface=XFCE_IFACE)

        # open each folder and select the first file we have selected
        for dirname, sub_songs in group_songs(songs).items():
            bus_iface.DisplayFolderAndSelect(
                fsn2uri(dirname),
                sub_songs[0]("~basename"),
                display,
                get_startup_id())
    except dbus.DBusException as e:
        raise BrowseError(e)
开发者ID:faubiguy,项目名称:quodlibet,代码行数:23,代码来源:browsefolders.py


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