Revert "mpd: 'private' fields start with an _"

This reverts commit f2000d6e6d.

I did not have the code fresh in mind when saying that these should be prefixed
with _. As they are accessed from other classes, they are indeed public, and
should not be prefixed. My bad.
This commit is contained in:
Stein Magnus Jodal 2013-04-09 23:26:23 +02:00
parent f2000d6e6d
commit 27ff2e5f0a
3 changed files with 14 additions and 14 deletions

View File

@ -232,9 +232,9 @@ class MpdContext(object):
#: The subsytems that we want to be notified about in idle mode.
subscriptions = None
_playlist_uri_from_name = None
playlist_uri_from_name = None
_playlist_name_from_uri = None
playlist_name_from_uri = None
def __init__(self, dispatcher, session=None, core=None):
self.dispatcher = dispatcher
@ -242,14 +242,14 @@ class MpdContext(object):
self.core = core
self.events = set()
self.subscriptions = set()
self._playlist_uri_from_name = {}
self._playlist_name_from_uri = {}
self.playlist_uri_from_name = {}
self.playlist_name_from_uri = {}
self.refresh_playlists_mapping()
def create_unique_name(self, playlist_name):
name = playlist_name
i = 1
while name in self._playlist_uri_from_name:
while name in self.playlist_uri_from_name:
name = '%s [%d]' % (playlist_name, i)
i += 1
return name
@ -260,11 +260,11 @@ class MpdContext(object):
MPD
"""
if self.core is not None:
self._playlist_uri_from_name.clear()
self._playlist_name_from_uri.clear()
self.playlist_uri_from_name.clear()
self.playlist_name_from_uri.clear()
for playlist in self.core.playlists.playlists.get():
if not playlist.name:
continue
name = self.create_unique_name(playlist.name)
self._playlist_uri_from_name[name] = playlist.uri
self._playlist_name_from_uri[playlist.uri] = name
self.playlist_uri_from_name[name] = playlist.uri
self.playlist_name_from_uri[playlist.uri] = name

View File

@ -381,11 +381,11 @@ def searchaddpl(context, playlist_name, mpd_query):
return
results = context.core.library.search(**query).get()
if len(context._playlist_uri_from_name) == 0:
if len(context.playlist_uri_from_name) == 0:
context.refresh_playlists_mapping()
if playlist_name in context._playlist_uri_from_name:
uri = context._playlist_uri_from_name[playlist_name]
if playlist_name in context.playlist_uri_from_name:
uri = context.playlist_uri_from_name[playlist_name]
playlist = context.core.playlists.lookup(uri).get()
else:
playlist = context.core.playlists.create(playlist_name).get()

View File

@ -80,10 +80,10 @@ def listplaylists(context):
for playlist in context.core.playlists.playlists.get():
if not playlist.name:
continue
if playlist.uri not in context._playlist_name_from_uri:
if playlist.uri not in context.playlist_name_from_uri:
# the maps are not synced, we refresh them
context.refresh_playlists_mapping()
name = context._playlist_name_from_uri[playlist.uri]
name = context.playlist_name_from_uri[playlist.uri]
result.append(('playlist', name))
last_modified = (
playlist.last_modified or dt.datetime.utcnow()).isoformat()