MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / create_dummy_func

Function create_dummy_func

tensorpack/utils/develop.py:49–67  ·  view source on GitHub ↗

When a dependency of a function is not available, create a dummy function which throws ImportError when used. Args: func (str): name of the function. dependency (str or list[str]): name(s) of the dependency. Returns: function: a function object

(func, dependency)

Source from the content-addressed store, hash-verified

47
48
49def create_dummy_func(func, dependency):
50 """
51 When a dependency of a function is not available, create a dummy function which throws ImportError when used.
52
53 Args:
54 func (str): name of the function.
55 dependency (str or list[str]): name(s) of the dependency.
56
57 Returns:
58 function: a function object
59 """
60 assert not building_rtfd()
61
62 if isinstance(dependency, (list, tuple)):
63 dependency = ','.join(dependency)
64
65 def _dummy(*args, **kwargs):
66 raise ImportError("Cannot import '{}', therefore '{}' is not available".format(dependency, func))
67 return _dummy
68
69
70def building_rtfd():

Callers 2

viz.pyFile · 0.85
summary.pyFile · 0.85

Calls 2

building_rtfdFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected