def _browse_path(self, uri, encoding=sys.getfilesystemencoding()): root = local_uri_to_path(uri, b'') dirs, tracks = [], [] for file in sorted(os.listdir(os.path.join(self._media_dir, root))): path = os.path.join(root, file) name = file.decode(encoding, 'replace') if os.path.isdir(os.path.join(self._media_dir, path)): uri = translator.path_to_local_directory_uri(path) dirs.append(Ref.directory(uri=uri, name=name)) elif not path.lower().endswith(self._excluded_ext): uri = path_to_file_uri(os.path.join(self._media_dir, path)) tracks.append(Ref.track(uri=uri, name=name)) else: logger.debug('Skipped %s: File extension excluded.', path) return dirs + tracks
def test_path_to_file_uri(path, uri): assert translator.path_to_file_uri(path) == uri