Commit 64801957 authored by syrte's avatar syrte

import_all: skip single underscore

skip single underscore
minor restructure
parent a2a6cccf
...@@ -95,15 +95,16 @@ class CythonMagics(Magics): ...@@ -95,15 +95,16 @@ class CythonMagics(Magics):
def _import_all(self, module): def _import_all(self, module):
mdict = module.__dict__ mdict = module.__dict__
if '__all__' in mdict: if '__all__' in mdict:
for k in mdict['__all__']: keys = mdict['__all__']
if k in mdict:
self.shell.push({k:mdict[k]})
else: else:
raise AttributeError("'module' object has no attribute '%s'" % k) keys = [k for k in mdict if not k.startswith('_')]
else:
for k, v in mdict.items(): for k in keys:
if not k.startswith('__'): try:
self.shell.push({k:v}) self.shell.push({k: mdict[k]})
except KeyError:
msg = "'module' object has no attribute '%s'" % k
raise AttributeError(msg)
@cell_magic @cell_magic
def cython_inline(self, line, cell): def cython_inline(self, line, cell):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment