MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / resolve_backend

Method resolve_backend

lib/matplotlib/backends/registry.py:319–371  ·  view source on GitHub ↗

Return the backend and GUI framework for the specified backend name. If the GUI framework is not yet known then it will be determined by loading the backend module and checking the ``FigureCanvas.required_interactive_framework`` attribute. This function onl

(self, backend)

Source from the content-addressed store, hash-verified

317 return importlib.import_module(module_name)
318
319 def resolve_backend(self, backend):
320 """
321 Return the backend and GUI framework for the specified backend name.
322
323 If the GUI framework is not yet known then it will be determined by loading the
324 backend module and checking the ``FigureCanvas.required_interactive_framework``
325 attribute.
326
327 This function only loads entry points if they have not already been loaded and
328 the backend is not built-in and not of ``module://some.backend`` format.
329
330 Parameters
331 ----------
332 backend : str or None
333 Name of backend, or None to use the default backend.
334
335 Returns
336 -------
337 backend : str
338 The backend name.
339 framework : str or None
340 The GUI framework, which will be None for a backend that is non-interactive.
341 """
342 if isinstance(backend, str):
343 if not backend.startswith("module://"):
344 backend = backend.lower()
345 else: # Might be _auto_backend_sentinel or None
346 # Use whatever is already running...
347 from matplotlib import get_backend
348 backend = get_backend()
349
350 # Is backend already known (built-in or dynamically loaded)?
351 gui = (self._BUILTIN_BACKEND_TO_GUI_FRAMEWORK.get(backend) or
352 self._backend_to_gui_framework.get(backend))
353
354 # Is backend "module://something"?
355 if gui is None and isinstance(backend, str) and backend.startswith("module://"):
356 gui = "unknown"
357
358 # Is backend a possible entry point?
359 if gui is None and not self._loaded_entry_points:
360 self._ensure_entry_points_loaded()
361 gui = self._backend_to_gui_framework.get(backend)
362
363 # Backend known but not its gui framework.
364 if gui == "unknown":
365 gui = self._get_gui_framework_by_loading(backend)
366 self._backend_to_gui_framework[backend] = gui
367
368 if gui is None:
369 raise RuntimeError(f"'{backend}' is not a recognised backend name")
370
371 return backend, gui if gui != "headless" else None
372
373 def resolve_gui_or_backend(self, gui_or_backend):
374 """

Calls 4

get_backendFunction · 0.90
getMethod · 0.45

Tested by 1