MCPcopy Index your code
hub / github.com/ddserver/ddserver / require

Function require

ddserver/utils/deps.py:109–134  ·  view source on GitHub ↗

Decorator to inject requirements into a function. The decorated function is called with a named argument for each specified requirement containing the exported instances.

(**requirements)

Source from the content-addressed store, hash-verified

107
108
109def require(**requirements):
110 ''' Decorator to inject requirements into a function.
111
112 The decorated function is called with a named argument for each
113 specified requirement containing the exported instances.
114 '''
115
116 exports = {name : Export.load(requirement)
117 for name, requirement
118 in requirements.iteritems()}
119
120 def wrapper(func):
121 def wrapped(*args, **kwargs):
122 # Update the keyword arguments with the required instances
123 kwargs.update({name : export.instance
124 for name, export
125 in exports.iteritems()
126 if name not in kwargs})
127
128 return func(*args,
129 **kwargs)
130
131 wrapped.__name__ = func.__name__
132
133 return wrapped
134 return wrapper
135
136
137

Callers 2

wrapperFunction · 0.85
pwstrength.jsFile · 0.85

Calls 1

loadMethod · 0.80

Tested by

no test coverage detected