@contextlib.contextmanager
def namespace_tree_context(**kwargs):
 kwargs.setdefault('meta_path', sys.meta_path)
 kwargs.setdefault('path_hooks', sys.path_hooks)
 import_context = util.import_state(**kwargs)
 with import_context:
  with sys_modules_context():
   (yield)

@ contextlib . contextmanager def namespace_tree_context ( ** kwargs ) : kwargs . setdefault ( 'meta_path' , sys . meta_path ) kwargs . setdefault ( 'path_hooks' , sys . path_hooks ) import_context = util . import_state ( ** kwargs ) with import_context : with sys_modules_context ( ) : ( yield )
save import state and sys .