Permalink
Browse files

Rename MPD handler object name into something better

  • Loading branch information...
1 parent cb68779 commit 42ff4ba415100ed35e7bddb42622d193925df87a @multani committed Oct 31, 2011
Showing with 115 additions and 115 deletions.
  1. +14 −14 sonata/cli.py
  2. +26 −26 sonata/current.py
  3. +12 −12 sonata/library.py
  4. +49 −49 sonata/main.py
  5. +2 −2 sonata/mpdhelper.py
  6. +12 −12 sonata/playlists.py
View
@@ -126,9 +126,9 @@ def __init__(self, args):
args.apply_profile_arg(self.config)
c = mpd.MPDClient()
- self.MPDH = mpdh.MPDHelper(c)
+ self.mpd = mpdh.MPDHelper(c)
# XXX Should be configurable from the outside
- self.MPDH.suppress_error = True
+ self.mpd.suppress_errors = True
def mpd_connect(self):
host, port, password = misc.mpd_env_vars()
@@ -139,38 +139,38 @@ def mpd_connect(self):
if not password:
password = self.config.password[self.config.profile_num]
- self.MPDH.connect(host, port)
+ self.mpd.connect(host, port)
if password:
- self.MPDH.password(password)
+ self.mpd.password(password)
def execute_cmd(self, cmd):
- self.status = self.MPDH.status()
+ self.status = self.mpd.status()
if not self.status:
print _(('Unable to connect to MPD.\nPlease check your Sonata '
'preferences or MPD_HOST/MPD_PORT environment variables.'))
sys.exit(1)
- self.songinfo = self.MPDH.currentsong()
+ self.songinfo = self.mpd.currentsong()
getattr(self, "_execute_%s" % cmd)()
def _execute_play(self):
- self.MPDH.play()
+ self.mpd.play()
def _execute_pause(self):
- self.MPDH.pause(1)
+ self.mpd.pause(1)
def _execute_stop(self):
- self.MPDH.stop()
+ self.mpd.stop()
def _execute_next(self):
- self.MPDH.next()
+ self.mpd.next()
def _execute_prev(self):
- self.MPDH.previous()
+ self.mpd.previous()
def _execute_bool(self, cmd):
"""Set the reverse the value of cmd"""
- self.MPDH.call(cmd, int(not int(self.status[cmd])))
+ self.mpd.call(cmd, int(not int(self.status[cmd])))
def _execute_random(self):
self._execute_bool('random')
@@ -180,9 +180,9 @@ def _execute_repeat(self):
def _execute_pp(self):
if self.status['state'] in ['play']:
- self.MPDH.pause(1)
+ self.mpd.pause(1)
elif self.status['state'] in ['pause', 'stop']:
- self.MPDH.play()
+ self.mpd.play()
def _execute_info(self):
if self.status['state'] in ['play', 'pause']:
View
@@ -32,11 +32,11 @@
class Current(object):
- def __init__(self, config, MPDH, TAB_CURRENT, on_current_button_press,
+ def __init__(self, config, mpd, TAB_CURRENT, on_current_button_press,
connected, sonata_loaded, songinfo, update_statusbar,
iterate_now, libsearchfilter_get_style, new_tab):
self.config = config
- self.MPDH = MPDH
+ self.mpd = mpd
self.on_current_button_press = on_current_button_press
self.connected = connected
self.sonata_loaded = sonata_loaded
@@ -236,9 +236,9 @@ def current_update(self, prevstatus_playlist, new_playlist_length):
self.current.set_model(None)
if prevstatus_playlist:
- changed_songs = self.MPDH.plchanges(prevstatus_playlist)
+ changed_songs = self.mpd.plchanges(prevstatus_playlist)
else:
- changed_songs = self.MPDH.plchanges(0)
+ changed_songs = self.mpd.plchanges(0)
self.current_songs = []
newlen = int(new_playlist_length)
@@ -480,11 +480,11 @@ def sort(self, mode, column=None):
songs.sort(key=lambda x: x["sortby"])
pos = 0
- self.MPDH.command_list_ok_begin()
+ self.mpd.command_list_ok_begin()
for item in songs:
- self.MPDH.moveid(item["id"], pos)
+ self.mpd.moveid(item["id"], pos)
pos += 1
- self.MPDH.command_list_end()
+ self.mpd.command_list_end()
self.iterate_now()
self.header_update_column_indicators()
@@ -518,12 +518,12 @@ def on_sort_reverse(self, _action):
gtk.main_iteration()
top = 0
bot = len(self.currentdata)-1
- self.MPDH.command_list_ok_begin()
+ self.mpd.command_list_ok_begin()
while top < bot:
- self.MPDH.swap(top, bot)
+ self.mpd.swap(top, bot)
top = top + 1
bot = bot - 1
- self.MPDH.command_list_end()
+ self.mpd.command_list_end()
self.iterate_now()
def on_dnd(self, treeview, drag_context, x, y, selection, _info,
@@ -552,11 +552,11 @@ def on_dnd(self, treeview, drag_context, x, y, selection, _info,
paths[i] = paths[i][len(musicdir):]
if len(paths[i]) == 0:
paths[i] = "/"
- listallinfo = self.MPDH.listallinfo(paths[i])
+ listallinfo = self.mpd.listallinfo(paths[i])
for item in listallinfo:
if 'file' in item:
mpdpaths.append(mpdh.get(item, 'file'))
- elif self.MPDH.version >= (0, 14):
+ elif self.mpd.version >= (0, 14):
# Add local file, available in mpd 0.14. This currently
# work because python-mpd does not support unix socket
# paths, won't which is needed for authentication for
@@ -580,7 +580,7 @@ def on_dnd(self, treeview, drag_context, x, y, selection, _info,
else:
songid = len(self.currentdata)
for mpdpath in mpdpaths:
- self.MPDH.addid(mpdpath, songid)
+ self.mpd.addid(mpdpath, songid)
self.iterate_now()
return
@@ -603,7 +603,7 @@ def on_dnd(self, treeview, drag_context, x, y, selection, _info,
# We will manipulate self.current_songs and model to prevent
# the entire playlist from refreshing
offset = 0
- self.MPDH.command_list_ok_begin()
+ self.mpd.command_list_ok_begin()
for source in drag_sources:
index, i, songid, text = source
if drop_info:
@@ -616,10 +616,10 @@ def on_dnd(self, treeview, drag_context, x, y, selection, _info,
self.current_songs.insert(dest, self.current_songs[index])
if dest < index + 1:
self.current_songs.pop(index + 1)
- self.MPDH.moveid(songid, dest)
+ self.mpd.moveid(songid, dest)
else:
self.current_songs.pop(index)
- self.MPDH.moveid(songid, dest - 1)
+ self.mpd.moveid(songid, dest - 1)
model.insert(dest, model[index])
moved_iters += [model.get_iter((dest,))]
model.remove(i)
@@ -628,17 +628,17 @@ def on_dnd(self, treeview, drag_context, x, y, selection, _info,
self.current_songs[index])
if dest < index:
self.current_songs.pop(index + 1)
- self.MPDH.moveid(songid, dest + 1)
+ self.mpd.moveid(songid, dest + 1)
else:
self.current_songs.pop(index)
- self.MPDH.moveid(songid, dest)
+ self.mpd.moveid(songid, dest)
model.insert(dest + 1, model[index])
moved_iters += [model.get_iter((dest + 1,))]
model.remove(i)
else:
#dest = int(self.status['playlistlength']) - 1
dest = len(self.currentdata) - 1
- self.MPDH.moveid(songid, dest)
+ self.mpd.moveid(songid, dest)
self.current_songs.insert(dest + 1, self.current_songs[index])
self.current_songs.pop(index)
model.insert(dest + 1, model[index])
@@ -655,7 +655,7 @@ def on_dnd(self, treeview, drag_context, x, y, selection, _info,
# decreased by 1
if index < source[0] < dest:
source[0] -= 1
- self.MPDH.command_list_end()
+ self.mpd.command_list_end()
# we are manipulating the model manually for speed, so...
self.current_update_skip = True
@@ -680,7 +680,7 @@ def on_current_click(self, _treeview, path, _column):
return
try:
i = model.get_iter(path)
- self.MPDH.playid(self.current_get_songid(i, model))
+ self.mpd.playid(self.current_get_songid(i, model))
except:
pass
self.sel_rows = False
@@ -724,7 +724,7 @@ def searchfilter_on_enter(self, _entry):
song_id = self.current_get_songid(model.get_iter_first(), model)
if song_id:
self.searchfilter_toggle(None)
- self.MPDH.playid(song_id)
+ self.mpd.playid(song_id)
def searchfilter_feed_loop(self, editable):
# Lets only trigger the searchfilter_loop if 200ms pass
@@ -924,7 +924,7 @@ def on_remove(self):
if len(selected) == len(self.currentdata) and \
not self.filterbox_visible:
# Everything is selected, clear:
- self.MPDH.clear()
+ self.mpd.clear()
elif len(selected) > 0:
# we are manipulating the model manually for speed, so...
self.current_update_skip = True
@@ -933,18 +933,18 @@ def on_remove(self):
# If we remove an item from the filtered results, this
# causes a visual refresh in the interface.
self.current.set_model(None)
- self.MPDH.command_list_ok_begin()
+ self.mpd.command_list_ok_begin()
for path in selected:
if not self.filterbox_visible:
rownum = path[0]
else:
rownum = self.filter_row_mapping[path[0]]
i = self.currentdata.get_iter((rownum, 0))
- self.MPDH.deleteid(
+ self.mpd.deleteid(
self.current_get_songid(i, self.currentdata))
# Prevents the entire playlist from refreshing:
self.current_songs.pop(rownum)
self.currentdata.remove(i)
- self.MPDH.command_list_end()
+ self.mpd.command_list_end()
if not self.filterbox_visible:
self.current.set_model(model)
View
@@ -46,13 +46,13 @@ def library_get_data(data, *args):
class Library(object):
- def __init__(self, config, MPDH, artwork, TAB_LIBRARY, album_filename,
+ def __init__(self, config, mpd, artwork, TAB_LIBRARY, album_filename,
settings_save, filtering_entry_make_red,
filtering_entry_revert_color, filter_key_pressed,
on_add_item, connected, on_library_button_press, new_tab):
self.artwork = artwork
self.config = config
- self.MPDH = MPDH
+ self.mpd = mpd
self.librarymenu = None # cyclic dependency, set later
self.album_filename = album_filename
self.settings_save = settings_save
@@ -548,7 +548,7 @@ def library_populate_filesystem_data(self, path):
# Use cache if possible...
bd = self.lib_view_filesystem_cache
else:
- for item in self.MPDH.lsinfo(path):
+ for item in self.mpd.lsinfo(path):
if 'directory' in item:
name = mpdh.get(item, 'directory').split('/')[-1]
data = self.library_set_data(path=mpdh.get(item,
@@ -625,7 +625,7 @@ def library_populate_toplevel_data(self, genreview=False, artistview=False,
elif albumview:
albums = []
untagged_found = False
- for item in self.MPDH.listallinfo('/'):
+ for item in self.mpd.listallinfo('/'):
if 'file' in item and 'album' in item:
album = mpdh.get(item, 'album')
artist = mpdh.get(item, 'artist', self.NOTAG)
@@ -857,14 +857,14 @@ def library_return_list_items(self, itemtype, genre=None, artist=None,
for song in songs:
items.append(mpdh.get(song, itemtype))
else:
- items = self.MPDH.list(itemtype, *s)
+ items = self.mpd.list(itemtype, *s)
for item in items:
if len(item) > 0:
results.append(item)
else:
if genre is None and artist is None and album is None and year \
is None:
- for item in self.MPDH.list(itemtype):
+ for item in self.mpd.list(itemtype):
if len(item) > 0:
results.append(item)
if ignore_case:
@@ -885,7 +885,7 @@ def library_return_count(self, genre=None, artist=None, album=None,
num_songs = 0
for s in searches:
- if '' in s and self.MPDH.version <= (0, 13):
+ if '' in s and self.mpd.version <= (0, 13):
# Can't return count for empty tags, use search instead:
@@ -895,7 +895,7 @@ def library_return_count(self, genre=None, artist=None, album=None,
else:
- count = self.MPDH.count(*s)
+ count = self.mpd.count(*s)
playtime += mpdh.get(count, 'playtime', 0, True)
num_songs += mpdh.get(count, 'songs', 0, True)
@@ -996,7 +996,7 @@ def library_return_search_items(self, genre=None, artist=None, album=None,
num_songs = 0
results = []
- if '' in s and self.MPDH.version <= (0, 13):
+ if '' in s and self.mpd.version <= (0, 13):
# Can't search for empty tags, search broader and
# filter instead:
@@ -1016,7 +1016,7 @@ def library_return_search_items(self, genre=None, artist=None, album=None,
if len(args_tuple) == 0:
return None, 0, 0
- items = self.MPDH.search(*args_tuple)
+ items = self.mpd.search(*args_tuple)
if items is not None:
for item in items:
if strip_type is None or (strip_type is not None and not \
@@ -1263,7 +1263,7 @@ def get_path_child_filenames(self, return_root, selected_only=True):
def library_get_path_files_recursive(self, path):
results = []
- for item in self.MPDH.lsinfo(path):
+ for item in self.mpd.lsinfo(path):
if 'directory' in item:
results = results + self.library_get_path_files_recursive(
mpdh.get(item, 'directory'))
@@ -1373,7 +1373,7 @@ def libsearchfilter_do_search(self, searchby, todo):
if not self.prevlibtodo_base in todo:
# Do library search based on first two letters:
self.prevlibtodo_base = todo[:2]
- self.prevlibtodo_base_results = self.MPDH.search(searchby,
+ self.prevlibtodo_base_results = self.mpd.search(searchby,
self.prevlibtodo_base)
subsearch = False
else:
Oops, something went wrong.

0 comments on commit 42ff4ba

Please sign in to comment.