@@ -210,7 +210,11 @@ def print_RE_md(dictionary=None, fmt="simple", printing=True):
210210 ======================== ===================================
211211
212212 """
213- global RE
213+ try :
214+ from IPython import get_ipython
215+ RE = get_ipython ().user_ns ["RE" ]
216+ except AttributeError as _exc :
217+ RE = None
214218 dictionary = dictionary or RE .md
215219 md = dict (dictionary ) # copy of input for editing
216220 v = dictionary_table (md ["versions" ], fmt = fmt ) # sub-table
@@ -279,29 +283,7 @@ def show_ophyd_symbols(show_pv=True, printing=True, verbose=False, symbols=None)
279283 If True, also show ``str(obj``.
280284 symbols: dict (default: `globals()`)
281285 If None, use global symbol table.
282- If not None, use provided dictionary.
283-
284- **TIP** ``globals()`` only gets the module's globals
285-
286- To get ``globals()`` from the global namespace, need to
287- pass that from the global namespace into this function.
288- Define this function *in* the global namespace::
289-
290- from apstools import utils as APS_utils
291-
292- def show_ophyd_symbols(
293- show_pv=True,
294- printing=True,
295- verbose=False,
296- symbols=None
297- ):
298- symbols = symbols or globals()
299- return APS_utils.show_ophyd_symbols(
300- show_pv=show_pv,
301- printing=printing,
302- verbose=verbose,
303- symbols=symbols
304- )
286+ If not None, use provided dictionary.
305287
306288 EXAMPLE::
307289
@@ -333,7 +315,12 @@ def show_ophyd_symbols(
333315 table .addLabel ("EPICS PV" )
334316 if verbose :
335317 table .addLabel ("object representation" )
336- g = symbols or globals ()
318+ try :
319+ from IPython import get_ipython
320+ g = get_ipython ().user_ns
321+ except AttributeError as _exc :
322+ g = globals ()
323+ g = symbols or g
337324 for k , v in sorted (g .items ()):
338325 if isinstance (v , (ophyd .Signal , ophyd .Device )):
339326 row = [k , v .__class__ .__name__ ]
0 commit comments