Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def isnotebook():
try:
shell = get_ipython().__class__.__name__
if shell == 'ZMQInteractiveShell':
return True # Jupyter notebook or qtconsole
elif shell == 'TerminalInteractiveShell':
return False # Terminal running IPython
else:
return False # Other type (?)
except NameError:
return False # Probably standard Python interpreter
if isnotebook():
from saspy.sas_magic import SASMagic
get_ipython().register_magics(SASMagic)
def _find_cfg():
sp = []
sp[:] = sys.path
sp[0] = os.path.abspath(sp[0])
sp.insert(1, os.path.expanduser('~/.config/saspy'))
sp.insert(0, __file__.rsplit(os.sep+'__init__.py')[0])
cfg = 'Not found'
for dir in sp:
f1 = dir+os.sep+'sascfg_personal.py'
if os.path.isfile(f1):
cfg = f1
break
def __init__(self, shell):
super(SASMagic, self).__init__(shell)
self.lst_len = -99 # initialize the length to a negative number to trigger function
self.mva = None
if self.lst_len < 0 and isinstance(self.mva, SASsession) :
self._get_lst_len()
def load_ipython_extension(ipython):
"""Load the extension in Jupyter"""
ipython.register_magics(SASMagic)