Exemplo n.º 1
0
def _require(*modules, **mapping):
    """Helper for @require decorator."""
    from ipyparallel.error import UnmetDependency
    from ipyparallel.serialize import uncan
    user_ns = globals()
    for name in modules:
        try:
            exec('import %s' % name, user_ns)
        except ImportError:
            raise UnmetDependency(name)
            
    for name, cobj in mapping.items():
        user_ns[name] = uncan(cobj, user_ns)
    return True
Exemplo n.º 2
0
def _require(*modules, **mapping):
    """Helper for @require decorator."""
    from ipyparallel.error import UnmetDependency
    from ipyparallel.serialize import uncan
    user_ns = globals()
    for name in modules:
        try:
            exec('import %s' % name, user_ns)
        except ImportError:
            raise UnmetDependency(name)

    for name, cobj in mapping.items():
        user_ns[name] = uncan(cobj, user_ns)
    return True
Exemplo n.º 3
0
 def cancan(self, f):
     """decorator to pass through canning into self.user_ns"""
     return uncan(can(f), self.user_ns)