else:
self._c['playlist'].add_playlist(playlist)
+ def _postprocess_new_playlist(self, command, args={}, results=None):
+ """Update `self` to show the new playlist.
+ """
+ if not isinstance(results[-1], Success):
+ self._postprocess_text(command, results=results)
+ return
+ assert len(results) == 2, results
+ playlist = results[0]
+ if 'playlist' in self._c:
+ loaded = self._c['playlist'].is_playlist_loaded(playlist)
+ assert loaded == False, loaded
+ self._c['playlist'].add_playlist(playlist)
+
def _postprocess_load_playlist(self, command, args={}, results=None):
"""Update `self` to show the playlist.
"""
return
assert len(results) == 2, results
playlist = results[0]
- self._c['playlist'].update_playlist(playlist)
+ if 'playlist' in self._c:
+ loaded = self._c['playlist'].is_playlist_loaded(playlist)
+ assert loaded == True, loaded
+ self._c['playlist'].update_playlist(playlist)
def _postprocess_get_curve(self, command, args={}, results=[]):
"""Update `self` to show the curve.
else:
raise NotImplementedError()
if 'note' in self._c:
- self._c['note'].set_text(curve.info['note'])
+ self._c['note'].set_text(curve.info.get('note', ''))
if 'playlist' in self._c:
self._c['playlist'].set_selected_curve(
playlist, curve)
"""
pass
+ def _postprocess_glob_curves_to_playlist(
+ self, command, args={}, results=[]):
+ """Update `self` to show new curves.
+ """
+ if not isinstance(results[-1], Success):
+ self._postprocess_text(command, results=results)
+ return
+ if 'playlist' in self._c:
+ if args.get('playlist', None) != None:
+ playlist = args['playlist']
+ pname = playlist.name
+ loaded = self._c['playlist'].is_playlist_name_loaded(pname)
+ assert loaded == True, loaded
+ for curve in results[:-1]:
+ self._c['playlist']._add_curve(pname, curve)
+ else:
+ self.execute_command(
+ command=self._command_by_name('get playlist'))
+
def _postprocess_zero_block_surface_contact_point(
self, command, args={}, results=[]):
"""Update the curve, since the available columns may have changed.
"""Absorb changed `.index()`, etc.
"""
self._playlists[playlist.name] = playlist
+ cnames = []
+ for curve in playlist:
+ if (playlist.name, curve.name) not in self._id_for_name:
+ self._add_curve(playlist.name, curve)
+ cnames.append(curve.name)
+ dc = self._callbacks['delete_curve']
+ _dc = self._callbacks['_delete_curve']
+ self._callbacks['delete_curve'] = None
+ self._callbacks['_delete_curve'] = None
+ for name in self._id_for_name.keys():
+ if not self._is_curve(name):
+ continue
+ pname,cname = name
+ if pname != playlist.name:
+ continue
+ if cname not in cnames:
+ self.delete_curve(playlist.name, cname)
+ self._callbacks['delete_curve'] = dc
+ self._callbacks['_delete_curve'] = _dc
def is_playlist_loaded(self, playlist):
- """Return `True` if a playlist is loaded, `False` otherwise.
+ """Return `True` if `playlist` is loaded, `False` otherwise.
+ """
+ return self.is_playlist_name_loaded(playlist.name)
+
+ def is_playlist_name_loaded(self, name):
+ """Return `True` if a playlist named `name` is loaded, `False`
+ otherwise.
"""
- return playlist.name in self._playlists
+ return name in self._playlists
class Playlist (Panel, wx.Panel):