path: Update with respect to review comments in #427

This commit is contained in:
Thomas Adacmik 2013-04-27 02:21:27 +02:00
parent ba40c0032b
commit 085b44e52f
5 changed files with 12 additions and 7 deletions

View File

@ -1,7 +1,7 @@
from __future__ import unicode_literals
import logging
import os.path
import os
import pykka
@ -33,9 +33,12 @@ class LocalBackend(pykka.ThreadingActor, base.Backend):
logger.warning('Local media dir %s does not exist.' %
self.config['local']['media_dir'])
if not os.path.isdir(self.config['local']['playlists_dir']):
logger.warning('Local playlists dir %s does not exist.' %
self.config['local']['playlists_dir'])
try:
path.get_or_create_dir(self.config['local']['playlists_dir'])
except EnvironmentError as error:
logger.warning(
'Could not create local playlists dir: %s',
encoding.locale_decode(error))
try:
path.get_or_create_file(self.config['local']['tag_cache_file'])

View File

@ -31,6 +31,7 @@ def parse_m3u(file_path, media_dir):
- This function does not bother with Extended M3U directives.
"""
# TODO: uris as bytes
uris = []
try:
with open(file_path) as m3u:
@ -71,6 +72,7 @@ def parse_mpd_tag_cache(tag_cache, music_dir=''):
current = {}
state = None
# TODO: uris as bytes
for line in contents.split(b'\n'):
if line == b'songList begin':
state = 'songs'

View File

@ -236,7 +236,7 @@ def tracks_to_tag_cache_format(tracks, media_dir):
_add_to_tag_cache(result, dirs, files, media_dir)
return result
# TODO: bytes only
def _add_to_tag_cache(result, dirs, files, media_dir):
base_path = media_dir.encode('utf-8')

View File

@ -51,7 +51,7 @@ def main():
log.setup_log_levels(config)
if not config['local']['media_dir']:
logging.warning('local/media_dir is not set.')
logging.warning('Config value local/media_dir is not set.')
return
# TODO: missing error checking and other default setup code.

View File

@ -326,7 +326,7 @@ class ExpandedPathTest(unittest.TestCase):
def test_is_bytes(self):
self.assertIsInstance(types.ExpandedPath(b'/tmp', b'foo'), bytes)
def test_defaults_to_expanded(self,):
def test_defaults_to_expanded(self):
original = b'~'
expanded = b'expanded_path'
self.assertEqual(expanded, types.ExpandedPath(original, expanded))