本文整理汇总了Python中mpdhelper.call函数的典型用法代码示例。如果您正苦于以下问题:Python call函数的具体用法?Python call怎么用?Python call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了call函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: library_return_list_items
def library_return_list_items(self, itemtype, genre=None, artist=None, album=None, year=None, ignore_case=True):
# Returns all items of tag 'itemtype', in alphabetical order,
# using mpd's 'list'. If searchtype is passed, use
# a case insensitive search, via additional 'list'
# queries, since using a single 'list' call will be
# case sensitive.
results = []
searches = self.library_compose_list_count_searchlist(genre, artist, album, year)
if len(searches) > 0:
for s in searches:
# If we have untagged tags (''), use search instead
# of list because list will not return anything.
if '' in s:
items = []
songs, playtime, num_songs = self.library_return_search_items(genre, artist, album, year)
for song in songs:
items.append(mpdh.get(song, itemtype))
else:
items = mpdh.call(self.client, '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 mpdh.call(self.client, 'list', itemtype):
if len(item) > 0:
results.append(item)
if ignore_case:
results = misc.remove_list_duplicates(results, case=False)
results.sort(locale.strcoll)
return results
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:31,代码来源:library.py
示例2: on_playlist_save
def on_playlist_save(self, _action):
plname = self.prompt_for_playlist_name(_("Save Playlist"), 'savePlaylist')
if plname:
if self.playlist_name_exists(_("Save Playlist"), 'savePlaylistError', plname):
return
self.playlist_create(plname)
mpdh.call(self.client, 'playlistclear', plname)
self.add_selected_to_playlist(plname)
开发者ID:BackupTheBerlios,项目名称:sonata,代码行数:8,代码来源:playlists.py
示例3: on_playlist_menu_click
def on_playlist_menu_click(self, action):
plname = misc.unescape_html(action.get_name().replace("Playlist: ", ""))
response = ui.show_msg(self.window, _("Would you like to replace the existing playlist or append these songs?"), _("Existing Playlist"), "existingPlaylist", (_("Replace playlist"), 1, _("Append songs"), 2), default=self.config.existing_playlist_option)
if response == 1: # Overwrite
self.config.existing_playlist_option = response
mpdh.call(self.client, 'playlistclear', plname)
self.add_selected_to_playlist(plname)
elif response == 2: # Append songs:
self.config.existing_playlist_option = response
self.add_selected_to_playlist(plname)
开发者ID:BackupTheBerlios,项目名称:sonata,代码行数:10,代码来源:playlists.py
示例4: on_current_click
def on_current_click(self, _treeview, path, _column):
model = self.current.get_model()
if self.filterbox_visible:
self.searchfilter_on_enter(None)
return
try:
i = model.get_iter(path)
mpdh.call(self.client, "playid", self.current_get_songid(i, model))
except:
pass
self.sel_rows = False
self.iterate_now()
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:12,代码来源:current.py
示例5: mpd_connect
def mpd_connect(self):
host, port, password = misc.mpd_env_vars()
if not host:
host = self.config.host[self.config.profile_num]
if not port:
port = self.config.port[self.config.profile_num]
if not password:
password = self.config.password[self.config.profile_num]
mpdh.call(self.client, 'connect', host, port)
if password:
mpdh.call(self.client, 'password', password)
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:12,代码来源:cli.py
示例6: searchfilter_on_enter
def searchfilter_on_enter(self, _entry):
model, selected = self.current.get_selection().get_selected_rows()
song_id = None
if len(selected) > 0:
# If items are selected, play the first selected item:
song_id = self.current_get_songid(model.get_iter(selected[0]), model)
elif len(model) > 0:
# If nothing is selected: play the first item:
song_id = self.current_get_songid(model.get_iter_first(), model)
if song_id:
self.searchfilter_toggle(None)
mpdh.call(self.client, "playid", song_id)
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:12,代码来源:current.py
示例7: on_remove
def on_remove(self):
treeviewsel = self.current_selection
model, selected = treeviewsel.get_selected_rows()
if len(selected) == len(self.currentdata) and not self.filterbox_visible:
# Everything is selected, clear:
mpdh.call(self.client, "clear")
elif len(selected) > 0:
# we are manipulating the model manually for speed, so...
self.current_update_skip = True
selected.reverse()
if not self.filterbox_visible:
# If we remove an item from the filtered results, this
# causes a visual refresh in the interface.
self.current.set_model(None)
mpdh.call(self.client, "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))
mpdh.call(self.client, "deleteid", self.current_get_songid(i, self.currentdata))
# Prevents the entire playlist from refreshing:
self.current_songs.pop(rownum)
self.currentdata.remove(i)
mpdh.call(self.client, "command_list_end")
if not self.filterbox_visible:
self.current.set_model(model)
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:28,代码来源:current.py
示例8: playlist_name_exists
def playlist_name_exists(self, title, role, plname, skip_plname=""):
# If the playlist already exists, and the user does not want to replace it, return True; In
# all other cases, return False
playlists = mpdh.call(self.client, 'listplaylists')
if playlists is None:
playlists = mpdh.call(self.client, 'lsinfo')
for item in playlists:
if 'playlist' in item:
if mpdh.get(item, 'playlist') == plname and plname != skip_plname:
if ui.show_msg(self.window, _("A playlist with this name already exists. Would you like to replace it?"), title, role, gtk.BUTTONS_YES_NO) == gtk.RESPONSE_YES:
return False
else:
return True
return False
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:14,代码来源:playlists.py
示例9: populate
def populate(self):
if self.connected():
self.playlistsdata.clear()
playlistinfo = []
playlists = mpdh.call(self.client, 'listplaylists')
if playlists is None:
playlists = mpdh.call(self.client, 'lsinfo')
for item in playlists:
if 'playlist' in item:
playlistinfo.append(misc.escape_html(mpdh.get(item, 'playlist')))
playlistinfo.sort(key=lambda x: x.lower()) # Remove case sensitivity
for item in playlistinfo:
self.playlistsdata.append([gtk.STOCK_JUSTIFY_FILL, item])
if mpdh.mpd_major_version(self.client) >= 0.13:
self.populate_playlists_for_menu(playlistinfo)
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:15,代码来源:playlists.py
示例10: library_get_path_files_recursive
def library_get_path_files_recursive(self, path):
results = []
for item in mpdh.call(self.client, 'lsinfo', path):
if 'directory' in item:
results = results + self.library_get_path_files_recursive(mpdh.get(item, 'directory'))
elif 'file' in item:
results.append(mpdh.get(item, 'file'))
return results
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:8,代码来源:library.py
示例11: libsearchfilter_do_search
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 = mpdh.call(self.client, 'search', searchby, self.prevlibtodo_base)
subsearch = False
else:
subsearch = True
# Now, use filtering similar to playlist filtering:
# this make take some seconds... and we'll escape the search text because
# we'll be searching for a match in items that are also escaped.
todo = misc.escape_html(todo)
todo = re.escape(todo)
todo = '.*' + todo.replace(' ', ' .*').lower()
regexp = re.compile(todo)
matches = []
if searchby != 'any':
for row in self.prevlibtodo_base_results:
if regexp.match(unicode(mpdh.get(row, searchby)).lower()):
matches.append(row)
else:
for row in self.prevlibtodo_base_results:
for meta in row:
if regexp.match(unicode(mpdh.get(row, meta)).lower()):
matches.append(row)
break
if subsearch and len(matches) == len(self.librarydata):
# nothing changed..
return
self.library.freeze_child_notify()
currlen = len(self.librarydata)
newlist = []
for item in matches:
if 'file' in item:
newlist.append([self.sonatapb, self.library_set_data(path=mpdh.get(item, 'file')), self.parse_formatting(self.config.libraryformat, item, True)])
for i, item in enumerate(newlist):
if i < currlen:
j = self.librarydata.get_iter((i, ))
for index in range(len(item)):
if item[index] != self.librarydata.get_value(j, index):
self.librarydata.set_value(j, index, item[index])
else:
self.librarydata.append(item)
# Remove excess items...
newlen = len(newlist)
if newlen == 0:
self.librarydata.clear()
else:
for i in range(currlen-newlen):
j = self.librarydata.get_iter((currlen-1-i,))
self.librarydata.remove(j)
self.library.thaw_child_notify()
if len(matches) == 0:
gobject.idle_add(self.filtering_entry_make_red, self.searchtext)
else:
gobject.idle_add(self.library.set_cursor,'0')
gobject.idle_add(self.filtering_entry_revert_color, self.searchtext)
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:57,代码来源:library.py
示例12: playlist_create
def playlist_create(self, playlistname, oldname=None):
mpdh.call(self.client, 'rm', playlistname)
if oldname is not None:
mpdh.call(self.client, 'rename', oldname, playlistname)
else:
mpdh.call(self.client, 'save', playlistname)
self.populate()
self.iterate_now()
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:8,代码来源:playlists.py
示例13: library_return_count
def library_return_count(self, genre=None, artist=None, album=None, year=None):
# Because mpd's 'count' is case sensitive, we have to
# determine all equivalent items (case insensitive) and
# call 'count' for each of them. Using 'list' + 'count'
# involves much less data to be transferred back and
# forth than to use 'search' and count manually.
searches = self.library_compose_list_count_searchlist(genre, artist, album, year)
playtime = 0
num_songs = 0
for s in searches:
count = mpdh.call(self.client, 'count', *s)
playtime += int(mpdh.get(count, 'playtime'))
num_songs += int(mpdh.get(count, 'songs'))
return (playtime, num_songs)
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:14,代码来源:library.py
示例14: library_return_search_items
def library_return_search_items(self, genre=None, artist=None, album=None, year=None):
# Returns all mpd items, using mpd's 'search', along with
# playtime and num_songs.
searches = self.library_compose_search_searchlist(genre, artist, album, year)
for s in searches:
args_tuple = tuple(map(str, s))
playtime = 0
num_songs = 0
results = []
if '' in s and mpdh.mpd_major_version(self.client) <= 0.13:
# Can't search for empty tags, search broader and filter instead:
# Strip empty tag args from tuple:
pos = list(args_tuple).index('')
strip_type = list(args_tuple)[pos-1]
new_lst = []
for i, item in enumerate(list(args_tuple)):
if i != pos and i != pos-1:
new_lst.append(item)
args_tuple = tuple(new_lst)
else:
strip_type = None
if len(args_tuple) == 0:
return None, 0, 0
items = mpdh.call(self.client, '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 strip_type in item.keys()):
match = True
pos = 0
# Ensure that if, e.g., "foo" is searched, "foobar" isn't returned too
for arg in args_tuple[::2]:
if arg in item and unicode(mpdh.get(item, arg)).upper() != unicode(args_tuple[pos+1]).upper():
match = False
break
pos += 2
if match:
results.append(item)
num_songs += 1
playtime += mpdh.get(item, 'time', 0, True)
return (results, int(playtime), num_songs)
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:46,代码来源:library.py
示例15: library_return_search_items
def library_return_search_items(self, genre=None, artist=None, album=None, year=None):
# Returns all mpd items, using mpd's 'search', along with
# playtime and num_songs. Note that if one of the args is
# '', the search results will only be correct for mpd=0.14
searches = self.library_compose_search_searchlist(genre, artist, album, year)
for s in searches:
args_tuple = tuple(map(str, s))
playtime = 0
num_songs = 0
results = []
items = mpdh.call(self.client, 'search', *args_tuple)
if items is not None:
for item in items:
results.append(item)
num_songs += 1
playtime += int(mpdh.get(item, 'time', '0'))
return (results, int(playtime), num_songs)
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:17,代码来源:library.py
示例16: on_playlist_menu_click
def on_playlist_menu_click(self, action):
plname = misc.unescape_html(action.get_name().replace("Playlist: ", ""))
response = ui.show_msg(self.window, _("Would you like to replace the existing playlist or append these songs?"), _("Existing Playlist"), "existingPlaylist", (_("Replace playlist"), 1, _("Append songs"), 2), default=self.config.existing_playlist_option)
if response == 1: # Overwrite
self.config.existing_playlist_option = response
self.playlist_create(plname)
elif response == 2: # Append songs:
self.config.existing_playlist_option = response
mpdh.call(self.client, 'command_list_ok_begin')
for song in self.get_current_songs():
mpdh.call(self.client, 'playlistadd', plname, mpdh.get(song, 'file'))
mpdh.call(self.client, 'command_list_end')
return
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:13,代码来源:playlists.py
示例17: on_sort_reverse
def on_sort_reverse(self, _action):
if self.connected():
if not self.currentdata:
return
while gtk.events_pending():
gtk.main_iteration()
top = 0
bot = len(self.currentdata) - 1
mpdh.call(self.client, "command_list_ok_begin")
while top < bot:
mpdh.call(self.client, "swap", top, bot)
top = top + 1
bot = bot - 1
mpdh.call(self.client, "command_list_end")
self.iterate_now()
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:15,代码来源:current.py
示例18: library_populate_filesystem_data
def library_populate_filesystem_data(self, path):
# List all dirs/files at path
bd = []
if path == '/' and self.lib_view_filesystem_cache is not None:
# Use cache if possible...
bd = self.lib_view_filesystem_cache
else:
for item in mpdh.call(self.client, 'lsinfo', path):
if 'directory' in item:
name = mpdh.get(item, 'directory').split('/')[-1]
data = self.library_set_data(path=mpdh.get(item, 'directory'))
bd += [('d' + unicode(name).lower(), [self.openpb, data, misc.escape_html(name)])]
elif 'file' in item:
data = self.library_set_data(path=mpdh.get(item, 'file'))
bd += [('f' + unicode(mpdh.get(item, 'file')).lower(), [self.sonatapb, data, self.parse_formatting(self.config.libraryformat, item, True)])]
bd.sort(key=misc.first_of_2tuple)
if path != '/' and len(bd) > 0:
bd = self.library_populate_add_parent_rows() + bd
if path == '/':
self.lib_view_filesystem_cache = bd
return bd
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:21,代码来源:library.py
示例19: library_return_count
def library_return_count(self, genre=None, artist=None, album=None, year=None):
# Because mpd's 'count' is case sensitive, we have to
# determine all equivalent items (case insensitive) and
# call 'count' for each of them. Using 'list' + 'count'
# involves much less data to be transferred back and
# forth than to use 'search' and count manually.
searches = self.library_compose_list_count_searchlist(genre, artist, album, year)
playtime = 0
num_songs = 0
for s in searches:
if '' in s and mpdh.mpd_major_version(self.client) <= 0.13:
# Can't return count for empty tags, use search instead:
_results, playtime, num_songs = self.library_return_search_items(genre=genre, artist=artist, album=album, year=year)
else:
count = mpdh.call(self.client, 'count', *s)
playtime += mpdh.get(count, 'playtime', 0, True)
num_songs += mpdh.get(count, 'songs', 0, True)
return (playtime, num_songs)
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:24,代码来源:library.py
示例20: library_populate_toplevel_data
def library_populate_toplevel_data(self, genreview=False, artistview=False, albumview=False):
bd = self.library_get_toplevel_cache(genreview, artistview, albumview)
if bd is not None:
# We have our cached data, woot.
return bd
bd = []
if genreview or artistview:
# Only for artist/genre views, album view is handled differently
# since multiple artists can have the same album name
if genreview:
items = self.library_return_list_items('genre')
pb = self.genrepb
else:
items = self.library_return_list_items('artist')
pb = self.artistpb
if not (self.NOTAG in items):
items.append(self.NOTAG)
for item in items:
if genreview:
playtime, num_songs = self.library_return_count(genre=item)
data = self.library_set_data(genre=item)
else:
playtime, num_songs = self.library_return_count(artist=item)
data = self.library_set_data(artist=item)
display = misc.escape_html(item)
display += self.add_display_info(num_songs, int(playtime)/60)
bd += [(misc.lower_no_the(item), [pb, data, display])]
elif albumview:
albums = []
untagged_found = False
for item in mpdh.call(self.client, 'listallinfo', '/'):
if 'file' in item and 'album' in item:
album = mpdh.get(item, 'album')
artist = mpdh.get(item, 'artist', self.NOTAG)
year = mpdh.get(item, 'date', self.NOTAG)
filepath = os.path.dirname(mpdh.get(item, 'file'))
data = self.library_set_data(album=album, artist=artist, year=year, path=filepath)
albums.append(data)
if album == self.NOTAG:
untagged_found = True
if not untagged_found:
albums.append(self.library_set_data(album=self.NOTAG))
albums = misc.remove_list_duplicates(albums, case=False)
albums = self.list_identify_VA_albums(albums)
for item in albums:
album, artist, year, path = self.library_get_data(item, 'album', 'artist', 'year', 'path')
playtime, num_songs = self.library_return_count(artist=artist, album=album, year=year)
if num_songs > 0:
data = self.library_set_data(artist=artist, album=album, year=year, path=path)
cache_data = self.library_set_data(artist=artist, album=album, path=path)
display = misc.escape_html(album)
if artist and year and len(artist) > 0 and len(year) > 0 and artist != self.NOTAG and year != self.NOTAG:
display += " <span weight='light'>(" + misc.escape_html(artist) + ", " + misc.escape_html(year) + ")</span>"
elif artist and len(artist) > 0 and artist != self.NOTAG:
display += " <span weight='light'>(" + misc.escape_html(artist) + ")</span>"
elif year and len(year) > 0 and year != self.NOTAG:
display += " <span weight='light'>(" + misc.escape_html(year) + ")</span>"
display += self.add_display_info(num_songs, int(playtime)/60)
pb = self.artwork.get_library_artwork_cached_pb(cache_data, self.albumpb)
bd += [(misc.lower_no_the(album), [pb, data, display])]
bd.sort(locale.strcoll, key=misc.first_of_2tuple)
if genreview:
self.lib_view_genre_cache = bd
elif artistview:
self.lib_view_artist_cache = bd
elif albumview:
self.lib_view_album_cache = bd
return bd
开发者ID:BackupTheBerlios,项目名称:sonata-svn,代码行数:68,代码来源:library.py
注:本文中的mpdhelper.call函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论