##// END OF EJS Templates
use canning hook in dependent...
MinRK -
Show More
@@ -60,9 +60,11 b' class dependent(object):'
60 self.dargs = dargs
60 self.dargs = dargs
61 self.dkwargs = dkwargs
61 self.dkwargs = dkwargs
62
62
63 def __call__(self, *args, **kwargs):
63 def check_dependency(self):
64 if self.df(*self.dargs, **self.dkwargs) is False:
64 if self.df(*self.dargs, **self.dkwargs) is False:
65 raise UnmetDependency()
65 raise UnmetDependency()
66
67 def __call__(self, *args, **kwargs):
66 return self.f(*args, **kwargs)
68 return self.f(*args, **kwargs)
67
69
68 if not py3compat.PY3:
70 if not py3compat.PY3:
@@ -308,6 +308,11 b' def uncan_sequence(obj, g=None):'
308 else:
308 else:
309 return obj
309 return obj
310
310
311 def _uncan_dependent_hook(dep, g=None):
312 dep.check_dependency()
313
314 def can_dependent(obj):
315 return CannedObject(obj, keys=('f', 'df'), hook=_uncan_dependent_hook)
311
316
312 #-------------------------------------------------------------------------------
317 #-------------------------------------------------------------------------------
313 # API dictionaries
318 # API dictionaries
@@ -316,7 +321,7 b' def uncan_sequence(obj, g=None):'
316 # These dicts can be extended for custom serialization of new objects
321 # These dicts can be extended for custom serialization of new objects
317
322
318 can_map = {
323 can_map = {
319 'IPython.parallel.dependent' : lambda obj: CannedObject(obj, keys=('f','df')),
324 'IPython.parallel.dependent' : can_dependent,
320 'numpy.ndarray' : CannedArray,
325 'numpy.ndarray' : CannedArray,
321 FunctionType : CannedFunction,
326 FunctionType : CannedFunction,
322 bytes : CannedBytes,
327 bytes : CannedBytes,
General Comments 0
You need to be logged in to leave comments. Login now