MCPcopy Index your code
hub / github.com/prometheus/client_python / create

Method create

prometheus_client/decorator.py:207–226  ·  view source on GitHub ↗

Create a function from the strings name, signature and body. evaldict is the evaluation dictionary. If addsource is true an attribute __source__ is added to the result. The attributes attrs are added, if any.

(cls, obj, body, evaldict, defaults=None,
               doc=None, module=None, addsource=True, **attrs)

Source from the content-addressed store, hash-verified

205
206 @classmethod
207 def create(cls, obj, body, evaldict, defaults=None,
208 doc=None, module=None, addsource=True, **attrs):
209 """
210 Create a function from the strings name, signature and body.
211 evaldict is the evaluation dictionary. If addsource is true an
212 attribute __source__ is added to the result. The attributes attrs
213 are added, if any.
214 """
215 if isinstance(obj, str): # "name(signature)"
216 name, rest = obj.strip().split('(', 1)
217 signature = rest[:-1] # strip a right parens
218 func = None
219 else: # a function
220 name = None
221 signature = None
222 func = obj
223 self = cls(func, name, signature, defaults, doc, module)
224 ibody = '\n'.join(' ' + line for line in body.splitlines())
225 return self.make('def %(name)s(%(signature)s):\n' + ibody,
226 evaldict, addsource, **attrs)
227
228
229def decorate(func, caller):

Callers 4

decorateFunction · 0.45
decoratorFunction · 0.45
__call__Method · 0.45
gen_func_decFunction · 0.45

Calls 2

makeMethod · 0.95
joinMethod · 0.80

Tested by

no test coverage detected