Show More
@@ -401,13 +401,16 b' class DirectView(View):' | |||||
401 | return self.sync_imports(True) |
|
401 | return self.sync_imports(True) | |
402 |
|
402 | |||
403 | @contextmanager |
|
403 | @contextmanager | |
404 | def sync_imports(self, local=True): |
|
404 | def sync_imports(self, local=True, quiet=False): | |
405 | """Context Manager for performing simultaneous local and remote imports. |
|
405 | """Context Manager for performing simultaneous local and remote imports. | |
406 |
|
406 | |||
407 | 'import x as y' will *not* work. The 'as y' part will simply be ignored. |
|
407 | 'import x as y' will *not* work. The 'as y' part will simply be ignored. | |
408 |
|
408 | |||
409 | If `local=True`, then the package will also be imported locally. |
|
409 | If `local=True`, then the package will also be imported locally. | |
410 |
|
410 | |||
|
411 | If `quiet=True`, then no message concerning the success of import will be | |||
|
412 | reported. | |||
|
413 | ||||
411 | Note that remote-only (`local=False`) imports have not been implemented. |
|
414 | Note that remote-only (`local=False`) imports have not been implemented. | |
412 |
|
415 | |||
413 | >>> with view.sync_imports(): |
|
416 | >>> with view.sync_imports(): | |
@@ -456,10 +459,11 b' class DirectView(View):' | |||||
456 | key = name+':'+','.join(fromlist or []) |
|
459 | key = name+':'+','.join(fromlist or []) | |
457 | if level == -1 and key not in modules: |
|
460 | if level == -1 and key not in modules: | |
458 | modules.add(key) |
|
461 | modules.add(key) | |
459 |
if |
|
462 | if not quiet: | |
460 | print "importing %s from %s on engine(s)"%(','.join(fromlist), name) |
|
463 | if fromlist: | |
461 | else: |
|
464 | print "importing %s from %s on engine(s)"%(','.join(fromlist), name) | |
462 | print "importing %s on engine(s)"%name |
|
465 | else: | |
|
466 | print "importing %s on engine(s)"%name | |||
463 | results.append(self.apply_async(remote_import, name, fromlist, level)) |
|
467 | results.append(self.apply_async(remote_import, name, fromlist, level)) | |
464 | # restore override |
|
468 | # restore override | |
465 | __builtin__.__import__ = save_import |
|
469 | __builtin__.__import__ = save_import |
General Comments 0
You need to be logged in to leave comments.
Login now