MCPcopy Index your code
hub / github.com/ipython/ipython / aimport

Method aimport

IPython/extensions/autoreload.py:808–844  ·  view source on GitHub ↗

%aimport => Import modules for automatic reloading. %aimport List modules to automatically import and not to import. %aimport foo Import module 'foo' and mark it to be autoreloaded for %autoreload explicit %aimport foo, bar Import modules 'foo', 'ba

(self, parameter_s="", stream=None)

Source from the content-addressed store, hash-verified

806
807 @line_magic
808 def aimport(self, parameter_s="", stream=None):
809 """%aimport => Import modules for automatic reloading.
810
811 %aimport
812 List modules to automatically import and not to import.
813
814 %aimport foo
815 Import module 'foo' and mark it to be autoreloaded for %autoreload explicit
816
817 %aimport foo, bar
818 Import modules 'foo', 'bar' and mark them to be autoreloaded for %autoreload explicit
819
820 %aimport -foo, bar
821 Mark module 'foo' to not be autoreloaded for %autoreload explicit, all, or complete, and 'bar'
822 to be autoreloaded for mode explicit.
823 """
824 modname = parameter_s
825 if not modname:
826 to_reload = sorted(self._reloader.modules.keys())
827 to_skip = sorted(self._reloader.skip_modules.keys())
828 if stream is None:
829 stream = sys.stdout
830 if self._reloader.check_all:
831 stream.write("Modules to reload:\nall-except-skipped\n")
832 else:
833 stream.write("Modules to reload:\n%s\n" % " ".join(to_reload))
834 stream.write("\nModules to skip:\n%s\n" % " ".join(to_skip))
835 else:
836 for _module in [_.strip() for _ in modname.split(",")]:
837 if _module.startswith("-"):
838 _module = _module[1:].strip()
839 self._reloader.mark_module_skipped(_module)
840 else:
841 top_module, top_name = self._reloader.aimport_module(_module)
842
843 # Inject module to user namespace
844 self.shell.push({top_name: top_module})
845
846 def pre_run_cell(self, info):
847 # Store the execution info for later use in post_execute_hook

Callers 1

magic_aimportMethod · 0.80

Calls 5

keysMethod · 0.80
mark_module_skippedMethod · 0.80
aimport_moduleMethod · 0.80
writeMethod · 0.45
pushMethod · 0.45

Tested by 1

magic_aimportMethod · 0.64