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

Python path.uri_to_path函数代码示例

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

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



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

示例1: test_space_in_uri

 def test_space_in_uri(self):
     if sys.platform == 'win32':
         result = path.uri_to_path('file:///C://test%20this')
         self.assertEqual(result, 'C:/test this'.encode('utf-8'))
     else:
         result = path.uri_to_path('file:///tmp/test%20this')
         self.assertEqual(result, '/tmp/test this'.encode('utf-8'))
开发者ID:Halfnhav,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例2: test_simple_uri

 def test_simple_uri(self):
     if sys.platform == 'win32':
         result = path.uri_to_path('file:///C://WINDOWS/clock.avi')
         self.assertEqual(result, 'C:/WINDOWS/clock.avi'.encode('utf-8'))
     else:
         result = path.uri_to_path('file:///etc/fstab')
         self.assertEqual(result, '/etc/fstab'.encode('utf-8'))
开发者ID:Halfnhav,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例3: test_space_in_uri

 def test_space_in_uri(self):
     if sys.platform == "win32":
         result = uri_to_path("file:///C://test%20this")
         self.assertEqual(result, u"C:/test this")
     else:
         result = uri_to_path(u"file:///tmp/test%20this")
         self.assertEqual(result, u"/tmp/test this")
开发者ID:Amli,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例4: test_unicode_in_uri

 def test_unicode_in_uri(self):
     if sys.platform == 'win32':
         result = path.uri_to_path('file:///C://%C3%A6%C3%B8%C3%A5')
         self.assertEqual(result, 'C:/æøå'.encode('utf-8'))
     else:
         result = path.uri_to_path('file:///tmp/%C3%A6%C3%B8%C3%A5')
         self.assertEqual(result, '/tmp/æøå'.encode('utf-8'))
开发者ID:Halfnhav,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例5: test_unicode_in_uri

 def test_unicode_in_uri(self):
     if sys.platform == "win32":
         result = uri_to_path("file:///C://%C3%A6%C3%B8%C3%A5")
         self.assertEqual(result, u"C:/æøå")
     else:
         result = uri_to_path(u"file:///tmp/%C3%A6%C3%B8%C3%A5")
         self.assertEqual(result, u"/tmp/æøå")
开发者ID:Amli,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例6: test_latin1_in_uri

 def test_latin1_in_uri(self):
     if sys.platform == 'win32':
         result = path.uri_to_path('file:///C://%E6%F8%E5')
         self.assertEqual(result, 'C:/æøå'.encode('latin-1'))
     else:
         result = path.uri_to_path('file:///tmp/%E6%F8%E5')
         self.assertEqual(result, '/tmp/æøå'.encode('latin-1'))
开发者ID:Halfnhav,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例7: test_simple_uri

 def test_simple_uri(self):
     if sys.platform == "win32":
         result = uri_to_path("file:///C://WINDOWS/clock.avi")
         self.assertEqual(result, u"C:/WINDOWS/clock.avi")
     else:
         result = uri_to_path("file:///etc/fstab")
         self.assertEqual(result, u"/etc/fstab")
开发者ID:Amli,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例8: test_unicode_in_uri

 def test_unicode_in_uri(self):
     if sys.platform == 'win32':
         result = uri_to_path( 'file:///C://%C3%A6%C3%B8%C3%A5')
         self.assertEqual(result, u'C:/æøå')
     else:
         result = uri_to_path(u'file:///tmp/%C3%A6%C3%B8%C3%A5')
         self.assertEqual(result, u'/tmp/æøå')
开发者ID:arambelo,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例9: _save_m3u

 def _save_m3u(self, playlist):
     file_path = path.uri_to_path(playlist.uri)
     path.check_file_path_is_inside_base_dir(file_path, self._path)
     with open(file_path, 'w') as file_handle:
         for track in playlist.tracks:
             if track.uri.startswith('file://'):
                 uri = path.uri_to_path(track.uri)
             else:
                 uri = track.uri
             file_handle.write(uri + '\n')
开发者ID:0xadam,项目名称:mopidy,代码行数:10,代码来源:playlists.py


示例10: translate

 def translate(self, track):
     base_path = self.media_dir.encode('utf-8')
     result = dict(translator.track_to_mpd_format(track))
     result['file'] = uri_to_path(result['file'])[len(base_path) + 1:]
     result['key'] = os.path.basename(result['file'])
     result['mtime'] = mtime('')
     return translator.order_mpd_track_info(result.items())
开发者ID:Halfnhav,项目名称:mopidy,代码行数:7,代码来源:translator_test.py


示例11: change_track

 def change_track(self, track):
     media_dir = self.backend.config['local']['media_dir']
     # TODO: check that type is correct.
     file_path = path.uri_to_path(track.uri).split(b':', 1)[1]
     file_path = os.path.join(media_dir, file_path)
     track = track.copy(uri=path.path_to_uri(file_path))
     return super(LocalPlaybackProvider, self).change_track(track)
开发者ID:eisnerd,项目名称:mopidy,代码行数:7,代码来源:playback.py


示例12: translate

 def translate(self, track):
     base_path = self.media_dir.encode("utf-8")
     result = dict(translator.track_to_mpd_format(track))
     result["file"] = uri_to_path(result["file"])[len(base_path) + 1 :]
     result["key"] = os.path.basename(result["file"])
     result["mtime"] = mtime("")
     return translator.order_mpd_track_info(result.items())
开发者ID:vorodev,项目名称:mopidy,代码行数:7,代码来源:translator_test.py


示例13: translate

 def translate(self, track):
     folder = settings.LOCAL_MUSIC_PATH
     result = dict(translator.track_to_mpd_format(track))
     result['file'] = uri_to_path(result['file'])
     result['file'] = result['file'][len(folder)+1:]
     result['key'] = os.path.basename(result['file'])
     result['mtime'] = mtime('')
     return translator.order_mpd_track_info(result.items())
开发者ID:MechanisM,项目名称:mopidy,代码行数:8,代码来源:serializer_test.py


示例14: _rename_m3u

    def _rename_m3u(self, playlist):
        src_file_path = path.uri_to_path(playlist.uri)
        path.check_file_path_is_inside_base_dir(src_file_path, self._path)

        dst_file_path = self._get_m3u_path(playlist.name)
        path.check_file_path_is_inside_base_dir(dst_file_path, self._path)

        shutil.move(src_file_path, dst_file_path)

        return playlist.copy(uri=path.path_to_uri(dst_file_path))
开发者ID:0xadam,项目名称:mopidy,代码行数:10,代码来源:playlists.py


示例15: tracks_to_directory_tree

def tracks_to_directory_tree(tracks):
    directories = ({}, [])

    for track in tracks:
        path = b""
        current = directories

        absolute_track_dir_path = os.path.dirname(uri_to_path(track.uri))
        relative_track_dir_path = re.sub("^" + re.escape(settings.LOCAL_MUSIC_PATH), b"", absolute_track_dir_path)

        for part in split_path(relative_track_dir_path):
            path = os.path.join(path, part)
            if path not in current[0]:
                current[0][path] = ({}, [])
            current = current[0][path]
        current[1].append(track)
    return directories
开发者ID:jeremybmerrill,项目名称:mopidy,代码行数:17,代码来源:translator.py


示例16: process_application

    def process_application(self, bus, message):
        if message.src != self.fakesink:
            return

        if message.structure.get_name() != 'handoff':
            return

        uri = unicode(self.uribin.get_property('uri'))
        self.data['uri'] = uri
        self.data['mtime'] = os.path.getmtime(path.uri_to_path(uri))
        self.data[gst.TAG_DURATION] = self.get_duration()

        try:
            self.data_callback(self.data)
            self.next_uri()
        except KeyboardInterrupt:
            self.stop()
开发者ID:enraknes,项目名称:Pi-MusicBox,代码行数:17,代码来源:scanner.py


示例17: scan

 def scan(self, uri):
     logger.debug('Scanning %s for images', uri)
     data = self.scanner.scan(uri)
     images = []
     # Use image 'image' tag if available, or smaller, lower quality 'preview-image' otherwise
     for image in data['tags'].get('image', []) or data['tags'].get('preview-image', []):
         try:
             images.append(self.get_or_create_image_file(None, image.data))
         except Exception as e:
             logger.warn('Cannot extract images for %s: %s', uri, e)
     dirname = os.path.dirname(uri_to_path(uri))
     for pattern in self.patterns:
         for path in glob.glob(os.path.join(dirname, pattern)):
             try:
                 images.append(self.get_or_create_image(path))
             except Exception as e:
                 logger.warn('Cannot read album art from %s: %s', path, e)
     return images
开发者ID:jcass77,项目名称:mopidy-local-images,代码行数:18,代码来源:library.py


示例18: tracks_to_directory_tree

def tracks_to_directory_tree(tracks, media_dir):
    directories = ({}, [])

    for track in tracks:
        path = b''
        current = directories

        absolute_track_dir_path = os.path.dirname(uri_to_path(track.uri))
        relative_track_dir_path = re.sub(
            '^' + re.escape(media_dir), b'', absolute_track_dir_path)

        for part in split_path(relative_track_dir_path):
            path = os.path.join(path, part)
            if path not in current[0]:
                current[0][path] = ({}, [])
            current = current[0][path]
        current[1].append(track)
    return directories
开发者ID:abarisain,项目名称:mopidy,代码行数:18,代码来源:translator.py


示例19: tracks_to_directory_tree

def tracks_to_directory_tree(tracks):
    directories = ({}, [])
    for track in tracks:
        path = u''
        current = directories

        local_folder = settings.LOCAL_MUSIC_PATH
        track_path = uri_to_path(track.uri)
        track_path = re.sub('^' + re.escape(local_folder), '', track_path)
        track_dir = os.path.dirname(track_path)

        for part in split_path(track_dir):
            path = os.path.join(path, part)
            if path not in current[0]:
                current[0][path] = ({}, [])
            current = current[0][path]
        current[1].append(track)
    return directories
开发者ID:bok,项目名称:mopidy,代码行数:18,代码来源:translator.py


示例20: _add_to_tag_cache

def _add_to_tag_cache(result, dirs, files, media_dir):
    base_path = media_dir.encode('utf-8')

    for path, (entry_dirs, entry_files) in dirs.items():
        try:
            text_path = path.decode('utf-8')
        except UnicodeDecodeError:
            text_path = urllib.quote(path).decode('utf-8')
        name = os.path.split(text_path)[1]
        result.append(('directory', text_path))
        result.append(('mtime', get_mtime(os.path.join(base_path, path))))
        result.append(('begin', name))
        _add_to_tag_cache(result, entry_dirs, entry_files, media_dir)
        result.append(('end', name))

    result.append(('songList begin',))

    for track in files:
        track_result = dict(track_to_mpd_format(track))

        # XXX Don't save comments to the tag cache as they may span multiple
        # lines. We'll start saving track comments when we move from tag_cache
        # to a JSON file. See #579 for details.
        if 'Comment' in track_result:
            del track_result['Comment']

        path = uri_to_path(track_result['file'])
        try:
            text_path = path.decode('utf-8')
        except UnicodeDecodeError:
            text_path = urllib.quote(path).decode('utf-8')
        relative_path = os.path.relpath(path, base_path)
        relative_uri = urllib.quote(relative_path)

        # TODO: use track.last_modified
        track_result['file'] = relative_uri
        track_result['mtime'] = get_mtime(path)
        track_result['key'] = os.path.basename(text_path)
        track_result = order_mpd_track_info(track_result.items())

        result.extend(track_result)

    result.append(('songList end',))
开发者ID:abarisain,项目名称:mopidy,代码行数:43,代码来源:translator.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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