mpd: 'private' fields start with an _

This commit is contained in:
Thomas Refis 2013-04-09 21:31:36 +02:00
parent 5af26a226e
commit f2000d6e6d
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. #: The subsytems that we want to be notified about in idle mode.
subscriptions = None 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): def __init__(self, dispatcher, session=None, core=None):
self.dispatcher = dispatcher self.dispatcher = dispatcher
@ -242,14 +242,14 @@ class MpdContext(object):
self.core = core self.core = core
self.events = set() self.events = set()
self.subscriptions = set() self.subscriptions = set()
self.playlist_uri_from_name = {} self._playlist_uri_from_name = {}
self.playlist_name_from_uri = {} self._playlist_name_from_uri = {}
self.refresh_playlists_mapping() self.refresh_playlists_mapping()
def create_unique_name(self, playlist_name): def create_unique_name(self, playlist_name):
name = playlist_name name = playlist_name
i = 1 i = 1
while name in self.playlist_uri_from_name: while name in self._playlist_uri_from_name:
name = '%s [%d]' % (playlist_name, i) name = '%s [%d]' % (playlist_name, i)
i += 1 i += 1
return name return name
@ -260,11 +260,11 @@ class MpdContext(object):
MPD MPD
""" """
if self.core is not None: if self.core is not None:
self.playlist_uri_from_name.clear() self._playlist_uri_from_name.clear()
self.playlist_name_from_uri.clear() self._playlist_name_from_uri.clear()
for playlist in self.core.playlists.playlists.get(): for playlist in self.core.playlists.playlists.get():
if not playlist.name: if not playlist.name:
continue continue
name = self.create_unique_name(playlist.name) name = self.create_unique_name(playlist.name)
self.playlist_uri_from_name[name] = playlist.uri self._playlist_uri_from_name[name] = playlist.uri
self.playlist_name_from_uri[playlist.uri] = name self._playlist_name_from_uri[playlist.uri] = name

View File

@ -381,11 +381,11 @@ def searchaddpl(context, playlist_name, mpd_query):
return return
results = context.core.library.search(**query).get() 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() context.refresh_playlists_mapping()
if playlist_name in context.playlist_uri_from_name: if playlist_name in context._playlist_uri_from_name:
uri = context.playlist_uri_from_name[playlist_name] uri = context._playlist_uri_from_name[playlist_name]
playlist = context.core.playlists.lookup(uri).get() playlist = context.core.playlists.lookup(uri).get()
else: else:
playlist = context.core.playlists.create(playlist_name).get() 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(): for playlist in context.core.playlists.playlists.get():
if not playlist.name: if not playlist.name:
continue 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 # the maps are not synced, we refresh them
context.refresh_playlists_mapping() context.refresh_playlists_mapping()
name = context.playlist_name_from_uri[playlist.uri] name = context._playlist_name_from_uri[playlist.uri]
result.append(('playlist', name)) result.append(('playlist', name))
last_modified = ( last_modified = (
playlist.last_modified or dt.datetime.utcnow()).isoformat() playlist.last_modified or dt.datetime.utcnow()).isoformat()