Get rid of all kinds of abspath and expandpath usage that is no longer needed

This commit is contained in:
Thomas Adamcik 2010-10-31 23:51:10 +01:00
parent c513d0f6e7
commit fe309d374e
6 changed files with 10 additions and 23 deletions

View File

@ -15,8 +15,8 @@ logger = logging.getLogger('mopidy.backends.libspotify.session_manager')
# LibspotifySessionManager: Too many ancestors (9/7)
class LibspotifySessionManager(SpotifySessionManager, BaseThread):
cache_location = os.path.expanduser(settings.SPOTIFY_CACHE_PATH)
settings_location = os.path.expanduser(settings.SPOTIFY_CACHE_PATH)
cache_location = settings.SPOTIFY_CACHE_PATH
settings_location = settings.SPOTIFY_CACHE_PATH
appkey_file = os.path.join(os.path.dirname(__file__), 'spotify_appkey.key')
user_agent = 'Mopidy %s' % get_version()

View File

@ -66,7 +66,7 @@ class LocalPlaybackController(BasePlaybackController):
class LocalStoredPlaylistsController(BaseStoredPlaylistsController):
def __init__(self, *args):
super(LocalStoredPlaylistsController, self).__init__(*args)
self._folder = os.path.expanduser(settings.LOCAL_PLAYLIST_PATH)
self._folder = settings.LOCAL_PLAYLIST_PATH
self.refresh()
def lookup(self, uri):
@ -143,8 +143,8 @@ class LocalLibraryController(BaseLibraryController):
self.refresh()
def refresh(self, uri=None):
tag_cache = os.path.expanduser(settings.LOCAL_TAG_CACHE_FILE)
music_folder = os.path.expanduser(settings.LOCAL_MUSIC_PATH)
tag_cache = settings.LOCAL_TAG_CACHE_FILE
music_folder = settings.LOCAL_MUSIC_PATH
tracks = parse_mpd_tag_cache(tag_cache, music_folder)

View File

@ -129,7 +129,7 @@ def tracks_to_tag_cache_format(tracks):
def _add_to_tag_cache(result, folders, files):
for path, entry in folders.items():
name = os.path.split(path)[1]
music_folder = os.path.expanduser(settings.LOCAL_MUSIC_PATH)
music_folder = settings.LOCAL_MUSIC_PATH
mtime = get_mtime(os.path.join(music_folder, path))
result.append(('directory', path))
result.append(('mtime', mtime))
@ -150,7 +150,7 @@ def tracks_to_directory_tree(tracks):
path = u''
current = directories
local_folder = os.path.expanduser(settings.LOCAL_MUSIC_PATH)
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)

View File

@ -5,7 +5,6 @@ import pygst
pygst.require('0.10')
import gst
from os.path import abspath
import datetime
import sys
import threading

View File

@ -7,14 +7,12 @@ import urllib
logger = logging.getLogger('mopidy.utils.path')
def get_or_create_folder(folder):
folder = os.path.expanduser(folder)
if not os.path.isdir(folder):
logger.info(u'Creating dir %s', folder)
os.mkdir(folder, 0755)
return folder
def get_or_create_file(filename):
filename = os.path.expanduser(filename)
if not os.path.isfile(filename):
logger.info(u'Creating file %s', filename)
open(filename, 'w')
@ -22,7 +20,6 @@ def get_or_create_file(filename):
def path_to_uri(*paths):
path = os.path.join(*paths)
#path = os.path.expanduser(path) # FIXME Waiting for test case?
path = path.encode('utf-8')
if sys.platform == 'win32':
return 'file:' + urllib.pathname2url(path)
@ -46,16 +43,13 @@ def split_path(path):
return parts
def find_files(path):
path = os.path.expanduser(path)
if os.path.isfile(path):
filename = os.path.abspath(path)
if not isinstance(filename, unicode):
filename = filename.decode('utf-8')
yield filename
if not isinstance(path, unicode):
path = path.decode('utf-8')
yield path
else:
for dirpath, dirnames, filenames in os.walk(path):
for filename in filenames:
dirpath = os.path.abspath(dirpath)
filename = os.path.join(dirpath, filename)
if not isinstance(filename, unicode):
filename = filename.decode('utf-8')

View File

@ -34,9 +34,6 @@ class GetOrCreateFolderTest(unittest.TestCase):
self.assert_(os.path.isdir(self.parent))
self.assertEqual(created, self.parent)
def test_that_userfolder_is_expanded(self):
raise SkipTest # Not sure how to safely test this
class PathToFileURITest(unittest.TestCase):
def test_simple_path(self):
@ -139,9 +136,6 @@ class FindFilesTest(unittest.TestCase):
self.assert_(is_unicode(name),
'%s is not unicode object' % repr(name))
def test_expanduser(self):
raise SkipTest
class MtimeTest(unittest.TestCase):
def tearDown(self):