MCPcopy
hub / github.com/lektor/lektor / emit

Method emit

lektor/pluginsystem.py:160–188  ·  view source on GitHub ↗

Invoke event hook for all plugins that support it. Any ``kwargs`` are passed to the hook methods. Returns a dict mapping plugin ids to hook method return values.

(self, event, **kwargs)

Source from the content-addressed store, hash-verified

158 return self.env.plugins.values()
159
160 def emit(self, event, **kwargs):
161 """Invoke event hook for all plugins that support it.
162
163 Any ``kwargs`` are passed to the hook methods.
164
165 Returns a dict mapping plugin ids to hook method return values.
166 """
167 rv = {}
168 extra_flags = process_extra_flags(self.extra_flags)
169 funcname = "on_" + event.replace("-", "_")
170 for plugin in self.iter_plugins():
171 handler = getattr(plugin, funcname, None)
172 if handler is not None:
173 kw = {**kwargs, "extra_flags": extra_flags}
174 try:
175 inspect.signature(handler).bind(**kw)
176 except TypeError:
177 del kw["extra_flags"]
178 rv[plugin.id] = handler(**kw)
179 if "extra_flags" not in kw:
180 warnings.warn(
181 f"The plugin {plugin.id!r} function {funcname!r} does not "
182 "accept extra_flags. "
183 "It should be updated to accept `**extra` so that it will "
184 "not break if new parameters are passed to it by newer "
185 "versions of Lektor.",
186 DeprecationWarning,
187 )
188 return rv

Callers

nothing calls this directly

Calls 4

iter_pluginsMethod · 0.95
process_extra_flagsFunction · 0.90
warnMethod · 0.80
handlerFunction · 0.50

Tested by

no test coverage detected