Rename mopidy.utils to mopidy.internal
This commit is contained in:
parent
4c8c8cd927
commit
d8bcd7f273
@ -95,7 +95,7 @@ master_doc = 'index'
|
|||||||
project = 'Mopidy'
|
project = 'Mopidy'
|
||||||
copyright = '2009-2015, Stein Magnus Jodal and contributors'
|
copyright = '2009-2015, Stein Magnus Jodal and contributors'
|
||||||
|
|
||||||
from mopidy.utils.versioning import get_version
|
from mopidy.internal.versioning import get_version
|
||||||
release = get_version()
|
release = get_version()
|
||||||
version = '.'.join(release.split('.')[:2])
|
version = '.'.join(release.split('.')[:2])
|
||||||
|
|
||||||
|
|||||||
@ -434,8 +434,8 @@ Use of Mopidy APIs
|
|||||||
==================
|
==================
|
||||||
|
|
||||||
When writing an extension, you should only use APIs documented at
|
When writing an extension, you should only use APIs documented at
|
||||||
:ref:`api-ref`. Other parts of Mopidy, like :mod:`mopidy.utils`, may change at
|
:ref:`api-ref`. Other parts of Mopidy, like :mod:`mopidy.internal`, may change
|
||||||
any time and are not something extensions should use.
|
at any time and are not something extensions should use.
|
||||||
|
|
||||||
|
|
||||||
Logging in extensions
|
Logging in extensions
|
||||||
|
|||||||
@ -41,7 +41,7 @@ sys.argv[1:] = []
|
|||||||
|
|
||||||
|
|
||||||
from mopidy import commands, config as config_lib, ext
|
from mopidy import commands, config as config_lib, ext
|
||||||
from mopidy.utils import encoding, log, path, process, versioning
|
from mopidy.internal import encoding, log, path, process, versioning
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ def main():
|
|||||||
extension.setup(registry)
|
extension.setup(registry)
|
||||||
|
|
||||||
# Anything that wants to exit after this point must use
|
# Anything that wants to exit after this point must use
|
||||||
# mopidy.utils.process.exit_process as actors can have been started.
|
# mopidy.internal.process.exit_process as actors can have been started.
|
||||||
try:
|
try:
|
||||||
return args.command.run(args, proxied_config)
|
return args.command.run(args, proxied_config)
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
|
|||||||
@ -16,7 +16,7 @@ from mopidy import exceptions
|
|||||||
from mopidy.audio import playlists, utils
|
from mopidy.audio import playlists, utils
|
||||||
from mopidy.audio.constants import PlaybackState
|
from mopidy.audio.constants import PlaybackState
|
||||||
from mopidy.audio.listener import AudioListener
|
from mopidy.audio.listener import AudioListener
|
||||||
from mopidy.utils import deprecation, process
|
from mopidy.internal import deprecation, process
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import gst.pbutils # noqa
|
|||||||
|
|
||||||
from mopidy import exceptions
|
from mopidy import exceptions
|
||||||
from mopidy.audio import utils
|
from mopidy.audio import utils
|
||||||
from mopidy.utils import encoding
|
from mopidy.internal import encoding
|
||||||
|
|
||||||
_missing_plugin_desc = gst.pbutils.missing_plugin_message_get_description
|
_missing_plugin_desc = gst.pbutils.missing_plugin_message_get_description
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
import gobject
|
import gobject
|
||||||
|
|
||||||
from mopidy.utils import path
|
from mopidy.internal import path
|
||||||
|
|
||||||
gobject.threads_init()
|
gobject.threads_init()
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import gobject
|
|||||||
from mopidy import config as config_lib, exceptions
|
from mopidy import config as config_lib, exceptions
|
||||||
from mopidy.audio import Audio
|
from mopidy.audio import Audio
|
||||||
from mopidy.core import Core
|
from mopidy.core import Core
|
||||||
from mopidy.utils import deps, process, timer, versioning
|
from mopidy.internal import deps, process, timer, versioning
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ from mopidy.compat import configparser
|
|||||||
from mopidy.config import keyring
|
from mopidy.config import keyring
|
||||||
from mopidy.config.schemas import * # noqa
|
from mopidy.config.schemas import * # noqa
|
||||||
from mopidy.config.types import * # noqa
|
from mopidy.config.types import * # noqa
|
||||||
from mopidy.utils import path, versioning
|
from mopidy.internal import path, versioning
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import socket
|
|||||||
|
|
||||||
from mopidy import compat
|
from mopidy import compat
|
||||||
from mopidy.config import validators
|
from mopidy.config import validators
|
||||||
from mopidy.utils import log, path
|
from mopidy.internal import log, path
|
||||||
|
|
||||||
|
|
||||||
def decode(value):
|
def decode(value):
|
||||||
|
|||||||
@ -14,8 +14,8 @@ from mopidy.core.mixer import MixerController
|
|||||||
from mopidy.core.playback import PlaybackController
|
from mopidy.core.playback import PlaybackController
|
||||||
from mopidy.core.playlists import PlaylistsController
|
from mopidy.core.playlists import PlaylistsController
|
||||||
from mopidy.core.tracklist import TracklistController
|
from mopidy.core.tracklist import TracklistController
|
||||||
from mopidy.utils import versioning
|
from mopidy.internal import versioning
|
||||||
from mopidy.utils.deprecation import deprecated_property
|
from mopidy.internal.deprecation import deprecated_property
|
||||||
|
|
||||||
|
|
||||||
class Core(
|
class Core(
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import operator
|
|||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
from mopidy import compat, exceptions, models
|
from mopidy import compat, exceptions, models
|
||||||
from mopidy.utils import deprecation, validation
|
from mopidy.internal import deprecation, validation
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import contextlib
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from mopidy import exceptions
|
from mopidy import exceptions
|
||||||
from mopidy.utils import validation
|
from mopidy.internal import validation
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import urlparse
|
|||||||
from mopidy import models
|
from mopidy import models
|
||||||
from mopidy.audio import PlaybackState
|
from mopidy.audio import PlaybackState
|
||||||
from mopidy.core import listener
|
from mopidy.core import listener
|
||||||
from mopidy.utils import deprecation, validation
|
from mopidy.internal import deprecation, validation
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@ -6,8 +6,8 @@ import urlparse
|
|||||||
|
|
||||||
from mopidy import exceptions
|
from mopidy import exceptions
|
||||||
from mopidy.core import listener
|
from mopidy.core import listener
|
||||||
|
from mopidy.internal import deprecation, validation
|
||||||
from mopidy.models import Playlist, Ref
|
from mopidy.models import Playlist, Ref
|
||||||
from mopidy.utils import deprecation, validation
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@ -4,8 +4,8 @@ import logging
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
from mopidy.core import listener
|
from mopidy.core import listener
|
||||||
|
from mopidy.internal import deprecation, validation
|
||||||
from mopidy.models import TlTrack, Track
|
from mopidy.models import TlTrack, Track
|
||||||
from mopidy.utils import deprecation, validation
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import tornado.websocket
|
|||||||
from mopidy import exceptions, models, zeroconf
|
from mopidy import exceptions, models, zeroconf
|
||||||
from mopidy.core import CoreListener
|
from mopidy.core import CoreListener
|
||||||
from mopidy.http import handlers
|
from mopidy.http import handlers
|
||||||
from mopidy.utils import encoding, formatting, network
|
from mopidy.internal import encoding, formatting, network
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import tornado.websocket
|
|||||||
|
|
||||||
import mopidy
|
import mopidy
|
||||||
from mopidy import core, models
|
from mopidy import core, models
|
||||||
from mopidy.utils import encoding, jsonrpc
|
from mopidy.internal import encoding, jsonrpc
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import pygst
|
|||||||
pygst.require('0.10')
|
pygst.require('0.10')
|
||||||
import gst # noqa
|
import gst # noqa
|
||||||
|
|
||||||
from mopidy.utils import formatting
|
from mopidy.internal import formatting
|
||||||
|
|
||||||
|
|
||||||
def format_dependency_list(adapters=None):
|
def format_dependency_list(adapters=None):
|
||||||
@ -11,7 +11,7 @@ import gobject
|
|||||||
|
|
||||||
import pykka
|
import pykka
|
||||||
|
|
||||||
from mopidy.utils import encoding
|
from mopidy.internal import encoding
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -10,7 +10,7 @@ import urlparse
|
|||||||
|
|
||||||
from mopidy import compat, exceptions
|
from mopidy import compat, exceptions
|
||||||
from mopidy.compat import queue
|
from mopidy.compat import queue
|
||||||
from mopidy.utils import encoding, xdg
|
from mopidy.internal import encoding, xdg
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -7,8 +7,8 @@ import time
|
|||||||
|
|
||||||
from mopidy import commands, compat, exceptions
|
from mopidy import commands, compat, exceptions
|
||||||
from mopidy.audio import scan, utils
|
from mopidy.audio import scan, utils
|
||||||
|
from mopidy.internal import path
|
||||||
from mopidy.local import translator
|
from mopidy.local import translator
|
||||||
from mopidy.utils import path
|
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
@ -11,8 +11,8 @@ import tempfile
|
|||||||
|
|
||||||
import mopidy
|
import mopidy
|
||||||
from mopidy import compat, local, models
|
from mopidy import compat, local, models
|
||||||
|
from mopidy.internal import encoding, timer
|
||||||
from mopidy.local import search, storage, translator
|
from mopidy.local import search, storage, translator
|
||||||
from mopidy.utils import encoding, timer
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from __future__ import absolute_import, unicode_literals
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from mopidy.utils import encoding, path
|
from mopidy.internal import encoding, path
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@ -5,20 +5,20 @@ import os
|
|||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
from mopidy import compat
|
from mopidy import compat
|
||||||
from mopidy.utils.path import path_to_uri, uri_to_path
|
from mopidy.internal import path
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def local_track_uri_to_file_uri(uri, media_dir):
|
def local_track_uri_to_file_uri(uri, media_dir):
|
||||||
return path_to_uri(local_track_uri_to_path(uri, media_dir))
|
return path.path_to_uri(local_track_uri_to_path(uri, media_dir))
|
||||||
|
|
||||||
|
|
||||||
def local_track_uri_to_path(uri, media_dir):
|
def local_track_uri_to_path(uri, media_dir):
|
||||||
if not uri.startswith('local:track:'):
|
if not uri.startswith('local:track:'):
|
||||||
raise ValueError('Invalid URI.')
|
raise ValueError('Invalid URI.')
|
||||||
file_path = uri_to_path(uri).split(b':', 1)[1]
|
file_path = path.uri_to_path(uri).split(b':', 1)[1]
|
||||||
return os.path.join(media_dir, file_path)
|
return os.path.join(media_dir, file_path)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,9 +5,9 @@ import logging
|
|||||||
import pykka
|
import pykka
|
||||||
|
|
||||||
from mopidy import backend
|
from mopidy import backend
|
||||||
|
from mopidy.internal import encoding, path
|
||||||
from mopidy.m3u.library import M3ULibraryProvider
|
from mopidy.m3u.library import M3ULibraryProvider
|
||||||
from mopidy.m3u.playlists import M3UPlaylistsProvider
|
from mopidy.m3u.playlists import M3UPlaylistsProvider
|
||||||
from mopidy.utils import encoding, path
|
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
@ -7,9 +7,8 @@ import urllib
|
|||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
from mopidy import compat
|
from mopidy import compat
|
||||||
|
from mopidy.internal import encoding, path
|
||||||
from mopidy.models import Track
|
from mopidy.models import Track
|
||||||
from mopidy.utils.encoding import locale_decode
|
|
||||||
from mopidy.utils.path import path_to_uri, uri_to_path
|
|
||||||
|
|
||||||
|
|
||||||
M3U_EXTINF_RE = re.compile(r'#EXTINF:(-1|\d+),(.*)')
|
M3U_EXTINF_RE = re.compile(r'#EXTINF:(-1|\d+),(.*)')
|
||||||
@ -20,7 +19,7 @@ logger = logging.getLogger(__name__)
|
|||||||
def playlist_uri_to_path(uri, playlists_dir):
|
def playlist_uri_to_path(uri, playlists_dir):
|
||||||
if not uri.startswith('m3u:'):
|
if not uri.startswith('m3u:'):
|
||||||
raise ValueError('Invalid URI %s' % uri)
|
raise ValueError('Invalid URI %s' % uri)
|
||||||
file_path = uri_to_path(uri)
|
file_path = path.uri_to_path(uri)
|
||||||
return os.path.join(playlists_dir, file_path)
|
return os.path.join(playlists_dir, file_path)
|
||||||
|
|
||||||
|
|
||||||
@ -80,7 +79,7 @@ def parse_m3u(file_path, media_dir=None):
|
|||||||
with open(file_path) as m3u:
|
with open(file_path) as m3u:
|
||||||
contents = m3u.readlines()
|
contents = m3u.readlines()
|
||||||
except IOError as error:
|
except IOError as error:
|
||||||
logger.warning('Couldn\'t open m3u: %s', locale_decode(error))
|
logger.warning('Couldn\'t open m3u: %s', encoding.locale_decode(error))
|
||||||
return tracks
|
return tracks
|
||||||
|
|
||||||
if not contents:
|
if not contents:
|
||||||
@ -100,11 +99,11 @@ def parse_m3u(file_path, media_dir=None):
|
|||||||
if urlparse.urlsplit(line).scheme:
|
if urlparse.urlsplit(line).scheme:
|
||||||
tracks.append(track.replace(uri=line))
|
tracks.append(track.replace(uri=line))
|
||||||
elif os.path.normpath(line) == os.path.abspath(line):
|
elif os.path.normpath(line) == os.path.abspath(line):
|
||||||
path = path_to_uri(line)
|
uri = path.path_to_uri(line)
|
||||||
tracks.append(track.replace(uri=path))
|
tracks.append(track.replace(uri=uri))
|
||||||
elif media_dir is not None:
|
elif media_dir is not None:
|
||||||
path = path_to_uri(os.path.join(media_dir, line))
|
uri = path.path_to_uri(os.path.join(media_dir, line))
|
||||||
tracks.append(track.replace(uri=path))
|
tracks.append(track.replace(uri=uri))
|
||||||
|
|
||||||
track = Track()
|
track = Track()
|
||||||
return tracks
|
return tracks
|
||||||
|
|||||||
@ -4,8 +4,8 @@ import copy
|
|||||||
import itertools
|
import itertools
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.models.fields import Field
|
from mopidy.models.fields import Field
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
|
|
||||||
class ImmutableObject(object):
|
class ImmutableObject(object):
|
||||||
|
|||||||
@ -6,8 +6,8 @@ import pykka
|
|||||||
|
|
||||||
from mopidy import exceptions, zeroconf
|
from mopidy import exceptions, zeroconf
|
||||||
from mopidy.core import CoreListener
|
from mopidy.core import CoreListener
|
||||||
|
from mopidy.internal import encoding, network, process
|
||||||
from mopidy.mpd import session, uri_mapper
|
from mopidy.mpd import session, uri_mapper
|
||||||
from mopidy.utils import encoding, network, process
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@ -2,8 +2,8 @@ from __future__ import absolute_import, unicode_literals
|
|||||||
|
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.mpd import exceptions, protocol, translator
|
from mopidy.mpd import exceptions, protocol, translator
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
|
|
||||||
@protocol.commands.add('add')
|
@protocol.commands.add('add')
|
||||||
|
|||||||
@ -3,9 +3,9 @@ from __future__ import absolute_import, unicode_literals
|
|||||||
import functools
|
import functools
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.models import Track
|
from mopidy.models import Track
|
||||||
from mopidy.mpd import exceptions, protocol, translator
|
from mopidy.mpd import exceptions, protocol, translator
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
_SEARCH_MAPPING = {
|
_SEARCH_MAPPING = {
|
||||||
'album': 'album',
|
'album': 'album',
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
from __future__ import absolute_import, unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
from mopidy.core import PlaybackState
|
from mopidy.core import PlaybackState
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.mpd import exceptions, protocol
|
from mopidy.mpd import exceptions, protocol
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
|
|
||||||
@protocol.commands.add('consume', state=protocol.BOOL)
|
@protocol.commands.add('consume', state=protocol.BOOL)
|
||||||
|
|||||||
@ -2,8 +2,8 @@ from __future__ import absolute_import, unicode_literals
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from mopidy.internal import formatting, network
|
||||||
from mopidy.mpd import dispatcher, protocol
|
from mopidy.mpd import dispatcher, protocol
|
||||||
from mopidy.utils import formatting, network
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import pykka
|
|||||||
|
|
||||||
from mopidy import audio
|
from mopidy import audio
|
||||||
from mopidy.audio.constants import PlaybackState
|
from mopidy.audio.constants import PlaybackState
|
||||||
from mopidy.utils.path import path_to_uri
|
from mopidy.internal import path
|
||||||
|
|
||||||
from tests import dummy_audio, path_to_data_dir
|
from tests import dummy_audio, path_to_data_dir
|
||||||
|
|
||||||
@ -36,8 +36,8 @@ class BaseTest(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uris = [path_to_uri(path_to_data_dir('song1.wav')),
|
uris = [path.path_to_uri(path_to_data_dir('song1.wav')),
|
||||||
path_to_uri(path_to_data_dir('song2.wav'))]
|
path.path_to_uri(path_to_data_dir('song2.wav'))]
|
||||||
|
|
||||||
audio_class = audio.Audio
|
audio_class = audio.Audio
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class BaseTest(unittest.TestCase):
|
|||||||
'hostname': '',
|
'hostname': '',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
self.song_uri = path_to_uri(path_to_data_dir('song1.wav'))
|
self.song_uri = path.path_to_uri(path_to_data_dir('song1.wav'))
|
||||||
self.audio = self.audio_class.start(config=config, mixer=None).proxy()
|
self.audio = self.audio_class.start(config=config, mixer=None).proxy()
|
||||||
|
|
||||||
def tearDown(self): # noqa
|
def tearDown(self): # noqa
|
||||||
|
|||||||
@ -8,7 +8,7 @@ gobject.threads_init()
|
|||||||
|
|
||||||
from mopidy import exceptions
|
from mopidy import exceptions
|
||||||
from mopidy.audio import scan
|
from mopidy.audio import scan
|
||||||
from mopidy.utils import path as path_lib
|
from mopidy.internal import path as path_lib
|
||||||
|
|
||||||
from tests import path_to_data_dir
|
from tests import path_to_data_dir
|
||||||
|
|
||||||
|
|||||||
@ -373,7 +373,7 @@ class ExpandedPathTest(unittest.TestCase):
|
|||||||
expanded = b'expanded_path'
|
expanded = b'expanded_path'
|
||||||
self.assertEqual(expanded, types.ExpandedPath(original, expanded))
|
self.assertEqual(expanded, types.ExpandedPath(original, expanded))
|
||||||
|
|
||||||
@mock.patch('mopidy.utils.path.expand_path')
|
@mock.patch('mopidy.internal.path.expand_path')
|
||||||
def test_orginal_stores_unexpanded(self, expand_path_mock):
|
def test_orginal_stores_unexpanded(self, expand_path_mock):
|
||||||
original = b'~'
|
original = b'~'
|
||||||
expanded = b'expanded_path'
|
expanded = b'expanded_path'
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import mock
|
|||||||
import pykka
|
import pykka
|
||||||
|
|
||||||
from mopidy.core import Core
|
from mopidy.core import Core
|
||||||
from mopidy.utils import versioning
|
from mopidy.internal import versioning
|
||||||
|
|
||||||
|
|
||||||
class CoreActorTest(unittest.TestCase):
|
class CoreActorTest(unittest.TestCase):
|
||||||
|
|||||||
@ -7,8 +7,8 @@ import mock
|
|||||||
import pykka
|
import pykka
|
||||||
|
|
||||||
from mopidy import core
|
from mopidy import core
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.models import Track
|
from mopidy.models import Track
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
from tests import dummy_backend
|
from tests import dummy_backend
|
||||||
|
|
||||||
|
|||||||
@ -5,8 +5,8 @@ import unittest
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from mopidy import backend, core
|
from mopidy import backend, core
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.models import Image, Ref, SearchResult, Track
|
from mopidy.models import Image, Ref, SearchResult, Track
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
|
|
||||||
class BaseCoreLibraryTest(unittest.TestCase):
|
class BaseCoreLibraryTest(unittest.TestCase):
|
||||||
|
|||||||
@ -7,8 +7,8 @@ import mock
|
|||||||
import pykka
|
import pykka
|
||||||
|
|
||||||
from mopidy import backend, core
|
from mopidy import backend, core
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.models import Track
|
from mopidy.models import Track
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
from tests import dummy_audio as audio
|
from tests import dummy_audio as audio
|
||||||
|
|
||||||
|
|||||||
@ -5,8 +5,8 @@ import unittest
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from mopidy import backend, core
|
from mopidy import backend, core
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.models import Playlist, Ref, Track
|
from mopidy.models import Playlist, Ref, Track
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
|
|
||||||
class BasePlaylistsTest(unittest.TestCase):
|
class BasePlaylistsTest(unittest.TestCase):
|
||||||
|
|||||||
@ -5,8 +5,8 @@ import unittest
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from mopidy import backend, core
|
from mopidy import backend, core
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.models import TlTrack, Track
|
from mopidy.models import TlTrack, Track
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
|
|
||||||
class TracklistTest(unittest.TestCase):
|
class TracklistTest(unittest.TestCase):
|
||||||
|
|||||||
@ -11,7 +11,7 @@ from mock import Mock, call, patch, sentinel
|
|||||||
|
|
||||||
import pykka
|
import pykka
|
||||||
|
|
||||||
from mopidy.utils import network
|
from mopidy.internal import network
|
||||||
|
|
||||||
from tests import any_int, any_unicode
|
from tests import any_int, any_unicode
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ import unittest
|
|||||||
from mock import Mock, sentinel
|
from mock import Mock, sentinel
|
||||||
|
|
||||||
from mopidy import compat
|
from mopidy import compat
|
||||||
from mopidy.utils import network
|
from mopidy.internal import network
|
||||||
|
|
||||||
from tests import any_unicode
|
from tests import any_unicode
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ import gobject
|
|||||||
|
|
||||||
from mock import Mock, patch, sentinel
|
from mock import Mock, patch, sentinel
|
||||||
|
|
||||||
from mopidy.utils import network
|
from mopidy.internal import network
|
||||||
|
|
||||||
from tests import any_int
|
from tests import any_int
|
||||||
|
|
||||||
@ -5,18 +5,18 @@ import unittest
|
|||||||
|
|
||||||
from mock import Mock, patch
|
from mock import Mock, patch
|
||||||
|
|
||||||
from mopidy.utils import network
|
from mopidy.internal import network
|
||||||
|
|
||||||
|
|
||||||
class FormatHostnameTest(unittest.TestCase):
|
class FormatHostnameTest(unittest.TestCase):
|
||||||
|
|
||||||
@patch('mopidy.utils.network.has_ipv6', True)
|
@patch('mopidy.internal.network.has_ipv6', True)
|
||||||
def test_format_hostname_prefixes_ipv4_addresses_when_ipv6_available(self):
|
def test_format_hostname_prefixes_ipv4_addresses_when_ipv6_available(self):
|
||||||
network.has_ipv6 = True
|
network.has_ipv6 = True
|
||||||
self.assertEqual(network.format_hostname('0.0.0.0'), '::ffff:0.0.0.0')
|
self.assertEqual(network.format_hostname('0.0.0.0'), '::ffff:0.0.0.0')
|
||||||
self.assertEqual(network.format_hostname('1.0.0.1'), '::ffff:1.0.0.1')
|
self.assertEqual(network.format_hostname('1.0.0.1'), '::ffff:1.0.0.1')
|
||||||
|
|
||||||
@patch('mopidy.utils.network.has_ipv6', False)
|
@patch('mopidy.internal.network.has_ipv6', False)
|
||||||
def test_format_hostname_does_nothing_when_only_ipv4_available(self):
|
def test_format_hostname_does_nothing_when_only_ipv4_available(self):
|
||||||
network.has_ipv6 = False
|
network.has_ipv6 = False
|
||||||
self.assertEqual(network.format_hostname('0.0.0.0'), '0.0.0.0')
|
self.assertEqual(network.format_hostname('0.0.0.0'), '0.0.0.0')
|
||||||
@ -43,14 +43,14 @@ class TryIPv6SocketTest(unittest.TestCase):
|
|||||||
|
|
||||||
class CreateSocketTest(unittest.TestCase):
|
class CreateSocketTest(unittest.TestCase):
|
||||||
|
|
||||||
@patch('mopidy.utils.network.has_ipv6', False)
|
@patch('mopidy.internal.network.has_ipv6', False)
|
||||||
@patch('socket.socket')
|
@patch('socket.socket')
|
||||||
def test_ipv4_socket(self, socket_mock):
|
def test_ipv4_socket(self, socket_mock):
|
||||||
network.create_socket()
|
network.create_socket()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
socket_mock.call_args[0], (socket.AF_INET, socket.SOCK_STREAM))
|
socket_mock.call_args[0], (socket.AF_INET, socket.SOCK_STREAM))
|
||||||
|
|
||||||
@patch('mopidy.utils.network.has_ipv6', True)
|
@patch('mopidy.internal.network.has_ipv6', True)
|
||||||
@patch('socket.socket')
|
@patch('socket.socket')
|
||||||
def test_ipv6_socket(self, socket_mock):
|
def test_ipv6_socket(self, socket_mock):
|
||||||
network.create_socket()
|
network.create_socket()
|
||||||
@ -12,7 +12,7 @@ import pygst
|
|||||||
pygst.require('0.10')
|
pygst.require('0.10')
|
||||||
import gst # noqa
|
import gst # noqa
|
||||||
|
|
||||||
from mopidy.utils import deps
|
from mopidy.internal import deps
|
||||||
|
|
||||||
|
|
||||||
class DepsTest(unittest.TestCase):
|
class DepsTest(unittest.TestCase):
|
||||||
@ -4,16 +4,16 @@ import unittest
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from mopidy.utils.encoding import locale_decode
|
from mopidy.internal import encoding
|
||||||
|
|
||||||
|
|
||||||
@mock.patch('mopidy.utils.encoding.locale.getpreferredencoding')
|
@mock.patch('mopidy.internal.encoding.locale.getpreferredencoding')
|
||||||
class LocaleDecodeTest(unittest.TestCase):
|
class LocaleDecodeTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_can_decode_utf8_strings_with_french_content(self, mock):
|
def test_can_decode_utf8_strings_with_french_content(self, mock):
|
||||||
mock.return_value = 'UTF-8'
|
mock.return_value = 'UTF-8'
|
||||||
|
|
||||||
result = locale_decode(
|
result = encoding.locale_decode(
|
||||||
b'[Errno 98] Adresse d\xc3\xa9j\xc3\xa0 utilis\xc3\xa9e')
|
b'[Errno 98] Adresse d\xc3\xa9j\xc3\xa0 utilis\xc3\xa9e')
|
||||||
|
|
||||||
self.assertEqual('[Errno 98] Adresse d\xe9j\xe0 utilis\xe9e', result)
|
self.assertEqual('[Errno 98] Adresse d\xe9j\xe0 utilis\xe9e', result)
|
||||||
@ -22,7 +22,7 @@ class LocaleDecodeTest(unittest.TestCase):
|
|||||||
mock.return_value = 'UTF-8'
|
mock.return_value = 'UTF-8'
|
||||||
|
|
||||||
error = IOError(98, b'Adresse d\xc3\xa9j\xc3\xa0 utilis\xc3\xa9e')
|
error = IOError(98, b'Adresse d\xc3\xa9j\xc3\xa0 utilis\xc3\xa9e')
|
||||||
result = locale_decode(error)
|
result = encoding.locale_decode(error)
|
||||||
expected = '[Errno 98] Adresse d\xe9j\xe0 utilis\xe9e'
|
expected = '[Errno 98] Adresse d\xe9j\xe0 utilis\xe9e'
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -33,13 +33,13 @@ class LocaleDecodeTest(unittest.TestCase):
|
|||||||
def test_does_not_use_locale_to_decode_unicode_strings(self, mock):
|
def test_does_not_use_locale_to_decode_unicode_strings(self, mock):
|
||||||
mock.return_value = 'UTF-8'
|
mock.return_value = 'UTF-8'
|
||||||
|
|
||||||
locale_decode('abc')
|
encoding.locale_decode('abc')
|
||||||
|
|
||||||
self.assertFalse(mock.called)
|
self.assertFalse(mock.called)
|
||||||
|
|
||||||
def test_does_not_use_locale_to_decode_ascii_bytestrings(self, mock):
|
def test_does_not_use_locale_to_decode_ascii_bytestrings(self, mock):
|
||||||
mock.return_value = 'UTF-8'
|
mock.return_value = 'UTF-8'
|
||||||
|
|
||||||
locale_decode('abc')
|
encoding.locale_decode('abc')
|
||||||
|
|
||||||
self.assertFalse(mock.called)
|
self.assertFalse(mock.called)
|
||||||
@ -8,7 +8,7 @@ import mock
|
|||||||
import pykka
|
import pykka
|
||||||
|
|
||||||
from mopidy import core, models
|
from mopidy import core, models
|
||||||
from mopidy.utils import deprecation, jsonrpc
|
from mopidy.internal import deprecation, jsonrpc
|
||||||
|
|
||||||
from tests import dummy_backend
|
from tests import dummy_backend
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ import unittest
|
|||||||
import glib
|
import glib
|
||||||
|
|
||||||
from mopidy import compat, exceptions
|
from mopidy import compat, exceptions
|
||||||
from mopidy.utils import path
|
from mopidy.internal import path
|
||||||
|
|
||||||
import tests
|
import tests
|
||||||
|
|
||||||
@ -3,7 +3,7 @@ from __future__ import absolute_import, unicode_literals
|
|||||||
from pytest import raises
|
from pytest import raises
|
||||||
|
|
||||||
from mopidy import compat, exceptions
|
from mopidy import compat, exceptions
|
||||||
from mopidy.utils import validation
|
from mopidy.internal import validation
|
||||||
|
|
||||||
|
|
||||||
def test_check_boolean_with_valid_values():
|
def test_check_boolean_with_valid_values():
|
||||||
@ -6,7 +6,7 @@ import mock
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from mopidy.utils import xdg
|
from mopidy.internal import xdg
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.yield_fixture
|
||||||
@ -1,6 +1,6 @@
|
|||||||
from __future__ import absolute_import, unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
from mopidy.utils import deprecation
|
from mopidy.internal import deprecation
|
||||||
|
|
||||||
|
|
||||||
def generate_song(i):
|
def generate_song(i):
|
||||||
|
|||||||
@ -9,9 +9,9 @@ import pykka
|
|||||||
|
|
||||||
from mopidy import core
|
from mopidy import core
|
||||||
from mopidy.core import PlaybackState
|
from mopidy.core import PlaybackState
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.local import actor
|
from mopidy.local import actor
|
||||||
from mopidy.models import TlTrack, Track
|
from mopidy.models import TlTrack, Track
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
from tests import dummy_audio, path_to_data_dir
|
from tests import dummy_audio, path_to_data_dir
|
||||||
from tests.local import generate_song, populate_tracklist
|
from tests.local import generate_song, populate_tracklist
|
||||||
|
|||||||
@ -7,9 +7,9 @@ import pykka
|
|||||||
|
|
||||||
from mopidy import core
|
from mopidy import core
|
||||||
from mopidy.core import PlaybackState
|
from mopidy.core import PlaybackState
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.local import actor
|
from mopidy.local import actor
|
||||||
from mopidy.models import Playlist, Track
|
from mopidy.models import Playlist, Track
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
from tests import dummy_audio, path_to_data_dir
|
from tests import dummy_audio, path_to_data_dir
|
||||||
from tests.local import generate_song, populate_tracklist
|
from tests.local import generate_song, populate_tracklist
|
||||||
|
|||||||
@ -8,10 +8,10 @@ import unittest
|
|||||||
import pykka
|
import pykka
|
||||||
|
|
||||||
from mopidy import core
|
from mopidy import core
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.m3u import actor
|
from mopidy.m3u import actor
|
||||||
from mopidy.m3u.translator import playlist_uri_to_path
|
from mopidy.m3u.translator import playlist_uri_to_path
|
||||||
from mopidy.models import Playlist, Track
|
from mopidy.models import Playlist, Track
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
from tests import dummy_audio, path_to_data_dir
|
from tests import dummy_audio, path_to_data_dir
|
||||||
from tests.m3u import generate_song
|
from tests.m3u import generate_song
|
||||||
|
|||||||
@ -6,9 +6,9 @@ import os
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from mopidy.internal import path
|
||||||
from mopidy.m3u import translator
|
from mopidy.m3u import translator
|
||||||
from mopidy.models import Track
|
from mopidy.models import Track
|
||||||
from mopidy.utils import path
|
|
||||||
|
|
||||||
from tests import path_to_data_dir
|
from tests import path_to_data_dir
|
||||||
|
|
||||||
|
|||||||
@ -7,8 +7,8 @@ import mock
|
|||||||
import pykka
|
import pykka
|
||||||
|
|
||||||
from mopidy import core
|
from mopidy import core
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.mpd import session, uri_mapper
|
from mopidy.mpd import session, uri_mapper
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
from tests import dummy_backend, dummy_mixer
|
from tests import dummy_backend, dummy_mixer
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
from __future__ import absolute_import, unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.models import Ref, Track
|
from mopidy.models import Ref, Track
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
from tests.mpd import protocol
|
from tests.mpd import protocol
|
||||||
|
|
||||||
|
|||||||
@ -3,8 +3,8 @@ from __future__ import absolute_import, unicode_literals
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from mopidy.core import PlaybackState
|
from mopidy.core import PlaybackState
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.models import Track
|
from mopidy.models import Track
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
from tests.mpd import protocol
|
from tests.mpd import protocol
|
||||||
|
|
||||||
|
|||||||
@ -5,9 +5,9 @@ import unittest
|
|||||||
import pykka
|
import pykka
|
||||||
|
|
||||||
from mopidy import core
|
from mopidy import core
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.mpd.dispatcher import MpdDispatcher
|
from mopidy.mpd.dispatcher import MpdDispatcher
|
||||||
from mopidy.mpd.exceptions import MpdAckError
|
from mopidy.mpd.exceptions import MpdAckError
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
from tests import dummy_backend
|
from tests import dummy_backend
|
||||||
|
|
||||||
|
|||||||
@ -6,10 +6,10 @@ import pykka
|
|||||||
|
|
||||||
from mopidy import core
|
from mopidy import core
|
||||||
from mopidy.core import PlaybackState
|
from mopidy.core import PlaybackState
|
||||||
|
from mopidy.internal import deprecation
|
||||||
from mopidy.models import Track
|
from mopidy.models import Track
|
||||||
from mopidy.mpd import dispatcher
|
from mopidy.mpd import dispatcher
|
||||||
from mopidy.mpd.protocol import status
|
from mopidy.mpd.protocol import status
|
||||||
from mopidy.utils import deprecation
|
|
||||||
|
|
||||||
from tests import dummy_backend, dummy_mixer
|
from tests import dummy_backend, dummy_mixer
|
||||||
|
|
||||||
|
|||||||
@ -2,9 +2,9 @@ from __future__ import absolute_import, unicode_literals
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from mopidy.internal import path
|
||||||
from mopidy.models import Album, Artist, Playlist, TlTrack, Track
|
from mopidy.models import Album, Artist, Playlist, TlTrack, Track
|
||||||
from mopidy.mpd import translator
|
from mopidy.mpd import translator
|
||||||
from mopidy.utils.path import mtime
|
|
||||||
|
|
||||||
|
|
||||||
class TrackMpdFormatTest(unittest.TestCase):
|
class TrackMpdFormatTest(unittest.TestCase):
|
||||||
@ -27,10 +27,10 @@ class TrackMpdFormatTest(unittest.TestCase):
|
|||||||
|
|
||||||
def setUp(self): # noqa: N802
|
def setUp(self): # noqa: N802
|
||||||
self.media_dir = '/dir/subdir'
|
self.media_dir = '/dir/subdir'
|
||||||
mtime.set_fake_time(1234567)
|
path.mtime.set_fake_time(1234567)
|
||||||
|
|
||||||
def tearDown(self): # noqa: N802
|
def tearDown(self): # noqa: N802
|
||||||
mtime.undo_fake()
|
path.mtime.undo_fake()
|
||||||
|
|
||||||
def test_track_to_mpd_format_for_empty_track(self):
|
def test_track_to_mpd_format_for_empty_track(self):
|
||||||
# TODO: this is likely wrong, see:
|
# TODO: this is likely wrong, see:
|
||||||
|
|||||||
@ -11,9 +11,9 @@ import pygst
|
|||||||
pygst.require('0.10')
|
pygst.require('0.10')
|
||||||
import gst # noqa: pygst magic is needed to import correct gst
|
import gst # noqa: pygst magic is needed to import correct gst
|
||||||
|
|
||||||
|
from mopidy.internal import path
|
||||||
from mopidy.models import Track
|
from mopidy.models import Track
|
||||||
from mopidy.stream import actor
|
from mopidy.stream import actor
|
||||||
from mopidy.utils.path import path_to_uri
|
|
||||||
|
|
||||||
from tests import path_to_data_dir
|
from tests import path_to_data_dir
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ class LibraryProviderTest(unittest.TestCase):
|
|||||||
def setUp(self): # noqa: N802
|
def setUp(self): # noqa: N802
|
||||||
self.backend = mock.Mock()
|
self.backend = mock.Mock()
|
||||||
self.backend.uri_schemes = ['file']
|
self.backend.uri_schemes = ['file']
|
||||||
self.uri = path_to_uri(path_to_data_dir('song1.wav'))
|
self.uri = path.path_to_uri(path_to_data_dir('song1.wav'))
|
||||||
|
|
||||||
def test_lookup_ignores_unknown_scheme(self):
|
def test_lookup_ignores_unknown_scheme(self):
|
||||||
library = actor.StreamLibraryProvider(self.backend, 1000, [], {})
|
library = actor.StreamLibraryProvider(self.backend, 1000, [], {})
|
||||||
@ -34,7 +34,7 @@ class LibraryProviderTest(unittest.TestCase):
|
|||||||
self.assertEqual([Track(uri=self.uri)], library.lookup(self.uri))
|
self.assertEqual([Track(uri=self.uri)], library.lookup(self.uri))
|
||||||
|
|
||||||
def test_lookup_respects_blacklist_globbing(self):
|
def test_lookup_respects_blacklist_globbing(self):
|
||||||
blacklist = [path_to_uri(path_to_data_dir('')) + '*']
|
blacklist = [path.path_to_uri(path_to_data_dir('')) + '*']
|
||||||
library = actor.StreamLibraryProvider(self.backend, 100, blacklist, {})
|
library = actor.StreamLibraryProvider(self.backend, 100, blacklist, {})
|
||||||
self.assertEqual([Track(uri=self.uri)], library.lookup(self.uri))
|
self.assertEqual([Track(uri=self.uri)], library.lookup(self.uri))
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user