##// END OF EJS Templates
update qtconsole with user_expressions changes...
MinRK -
Show More
@@ -15,6 +15,7 b''
15 15 # Imports
16 16 #-----------------------------------------------------------------------------
17 17 # Stdlib
18 import json
18 19 import os
19 20 import re
20 21 import sys
@@ -327,14 +328,20 b' class MagicsManager(Configurable):'
327 328 return self._auto_status[self.auto_magic]
328 329
329 330 def lsmagic_info(self):
331 """Return the magics as a list of dicts"""
330 332 magic_list = []
331 for m_type in self.magics :
333 for m_type in self.magics:
332 334 for m_name,mgc in self.magics[m_type].items():
333 try :
335 try:
334 336 magic_list.append({'name':m_name,'type':m_type,'class':mgc.im_class.__name__})
335 except AttributeError :
337 except AttributeError:
336 338 magic_list.append({'name':m_name,'type':m_type,'class':'Other'})
337 339 return magic_list
340
341 def lsmagic_json(self):
342 """Wrap lsmagic_info() in a JSON object"""
343 from IPython.display import JSON
344 return JSON(json.dumps(self.lsmagic_info()))
338 345
339 346 def lsmagic(self):
340 347 """Return a dict of currently available magic functions.
@@ -241,7 +241,9 b' class HistoryConsoleWidget(ConsoleWidget):'
241 241 content = msg['content']
242 242 status = content['status']
243 243 if status == 'ok':
244 self._max_session_history=(int(content['user_expressions']['hlen']))
244 self._max_session_history = int(
245 content['user_expressions']['hlen']['data']['text/plain']
246 )
245 247
246 248 def save_magic(self):
247 249 # update the session history length
@@ -20,10 +20,10 b' Authors:'
20 20 #-----------------------------------------------------------------------------
21 21
22 22 # stdlib imports
23 import sys
23 import json
24 24 import re
25 import sys
25 26 import webbrowser
26 import ast
27 27 from threading import Thread
28 28
29 29 # System library imports
@@ -615,25 +615,25 b' class MainWindow(QtGui.QMainWindow):'
615 615 inner_dynamic_magic.__name__ = "dynamics_magic_s"
616 616 return inner_dynamic_magic
617 617
618 def populate_all_magic_menu(self, listofmagic=None):
619 """Clean "All Magics..." menu and repopulate it with `listofmagic`
618 def populate_all_magic_menu(self, display_data=None):
619 """Clean "All Magics..." menu and repopulate it with `display_data`
620 620
621 621 Parameters
622 622 ----------
623 listofmagic : string,
624 repr() of a list of strings, send back by the kernel
623 display_data : dict,
624 dict of display_data for the magics list.
625 Expects json data, as the result of MagicsManager.lsmagic_json()
625 626
626 Notes
627 -----
628 `listofmagic`is a repr() of list because it is fed with the result of
629 a 'user_expression'
630 627 """
631 628 for k,v in self._magic_menu_dict.items():
632 629 v.clear()
633 630 self.all_magic_menu.clear()
631
632 if not display_data:
633 return
634 634
635 mlist = json.loads(display_data['data'].get('application/json', []))
635 636
636 mlist=ast.literal_eval(listofmagic)
637 637 for magic in mlist:
638 638 cell = (magic['type'] == 'cell')
639 639 name = magic['name']
@@ -660,7 +660,7 b' class MainWindow(QtGui.QMainWindow):'
660 660 menu with the list received back
661 661
662 662 """
663 self.active_frontend._silent_exec_callback('get_ipython().magics_manager.lsmagic_info()',
663 self.active_frontend._silent_exec_callback('get_ipython().magics_manager.lsmagic_json()',
664 664 self.populate_all_magic_menu)
665 665
666 666 def _get_magic_menu(self,menuidentifier, menulabel=None):
General Comments 0
You need to be logged in to leave comments. Login now