Fix typos and formatting

This commit is contained in:
Jens Lütjen 2016-09-16 21:01:10 +02:00
parent 46dd36d914
commit 92767e49f9
7 changed files with 26 additions and 25 deletions

View File

@ -11,7 +11,7 @@ v2.1.0 (UNRELEASED)
Feature release.
- Core: Mopidy restores its last state when started. Can be enabled by setting
the config value :confval:`core/restore_state` to `true`.
the config value :confval:`core/restore_state` to ``true``.
- MPD: Fix MPD protocol for ``replay_gain_status`` command. The actual command
remains unimplemented. (PR: :issue:`1520`)

View File

@ -115,7 +115,7 @@ Core config section
When set to ``true``, Mopidy restores its last state when started.
The restored state includes the tracklist, playback history,
the playback state, and the mixers volume and mute state.
the playback state, the volume, and mute state.
Default is ``false``.

View File

@ -141,7 +141,7 @@ class Core(
CoreListener.send('stream_title_changed', title=title)
def setup(self):
""" Do not call this function. It is for internal use at startup."""
"""Do not call this function. It is for internal use at startup."""
try:
coverage = []
if self._config and 'restore_state' in self._config['core']:
@ -154,7 +154,7 @@ class Core(
logger.warn('Restore state: Unexpected error: %s', str(e))
def teardown(self):
""" Do not call this function. It is for internal use at shutdown."""
"""Do not call this function. It is for internal use at shutdown."""
try:
if self._config and 'restore_state' in self._config['core']:
if self._config['core']['restore_state']:
@ -164,8 +164,7 @@ class Core(
def _get_data_dir(self):
# get or create data director for core
data_dir_path = bytes(
os.path.join(self._config['core']['data_dir'], 'core'))
data_dir_path = os.path.join(self._config['core']['data_dir'], b'core')
path.get_or_create_dir(data_dir_path)
return data_dir_path
@ -174,8 +173,8 @@ class Core(
Save current state to disk.
"""
file_name = bytes(os.path.join(self._get_data_dir(), b'state.json.gz'))
logger.info('Save state to %s', file_name)
file_name = os.path.join(self._get_data_dir(), b'state.json.gz')
logger.info('Saveing state to %s', file_name)
data = {}
data['version'] = mopidy.__version__
@ -185,15 +184,15 @@ class Core(
playback=self.playback._save_state(),
mixer=self.mixer._save_state())
storage.dump(file_name, data)
logger.debug('Save state done.')
logger.debug('Saveing state done')
def _load_state(self, coverage):
"""
Restore state from disk.
Load state from disk and restore it. Parameter `coverage`
limits the amount data to restore. Possible
values for `coverage` (list of one or more of):
Load state from disk and restore it. Parameter ``coverage``
limits the amount of data to restore. Possible
values for ``coverage`` (list of one or more of):
- 'tracklist' fill the tracklist
- 'mode' set tracklist properties (consume, random, repeat, single)
@ -202,11 +201,11 @@ class Core(
- 'history' restore history
:param coverage: amount of data to restore
:type coverage: list of string (see above)
:type coverage: list of strings
"""
file_name = bytes(os.path.join(self._get_data_dir(), b'state.json.gz'))
logger.info('Load state from %s', file_name)
file_name = os.path.join(self._get_data_dir(), b'state.json.gz')
logger.info('Loading state from %s', file_name)
data = storage.load(file_name)
@ -224,7 +223,7 @@ class Core(
self.mixer._load_state(core_state.mixer, coverage)
# playback after tracklist
self.playback._load_state(core_state.playback, coverage)
logger.debug('Load state done.')
logger.debug('Loading state done')
class Backends(list):

View File

@ -64,11 +64,11 @@ class HistoryController(object):
count = 1
history_list = []
for timestamp, track in self._history:
history_list.append(HistoryTrack(
timestamp=timestamp, track=track))
history_list.append(
HistoryTrack(timestamp=timestamp, track=track))
count += 1
if count_max < count:
logger.info('Limiting history to %s tracks.', count_max)
logger.info('Limiting history to %s tracks', count_max)
break
return HistoryState(history=history_list)

View File

@ -23,7 +23,7 @@ def load(path):
"""
# Todo: raise an exception in case of error?
if not os.path.isfile(path):
logger.info('File does not exist: %s.', path)
logger.info('File does not exist: %s', path)
return {}
try:
with gzip.open(path, 'rb') as fp:

View File

@ -167,9 +167,10 @@ class JsonLibrary(local.Library):
self._tracks.pop(uri, None)
def close(self):
internal_storage.dump(self._json_file,
{'version': mopidy.__version__,
'tracks': self._tracks.values()})
internal_storage.dump(self._json_file, {
'version': mopidy.__version__,
'tracks': self._tracks.values()
})
def clear(self):
try:

View File

@ -56,7 +56,8 @@ class CoreActorSaveLoadStateTest(unittest.TestCase):
def setUp(self):
self.temp_dir = tempfile.mkdtemp()
self.state_file = os.path.join(self.temp_dir, 'core', 'state.json.gz')
self.state_file = os.path.join(self.temp_dir,
b'core', b'state.json.gz')
config = {
'core': {
@ -66,7 +67,7 @@ class CoreActorSaveLoadStateTest(unittest.TestCase):
}
}
os.mkdir(os.path.join(self.temp_dir, 'core'))
os.mkdir(os.path.join(self.temp_dir, b'core'))
self.mixer = dummy_mixer.create_proxy()
self.core = Core(