MCPcopy Index your code
hub / github.com/RustPython/RustPython / requires

Function requires

Lib/test/support/__init__.py:314–323  ·  view source on GitHub ↗

Raise ResourceDenied if the specified resource is not available.

(resource, msg=None)

Source from the content-addressed store, hash-verified

312 return use_resources.get(resource)
313
314def requires(resource, msg=None):
315 """Raise ResourceDenied if the specified resource is not available."""
316 if not is_resource_enabled(resource):
317 if msg is None:
318 msg = "Use of the %r resource not enabled" % resource
319 raise ResourceDenied(msg)
320 if resource in {"network", "urlfetch"} and not has_socket_support:
321 raise ResourceDenied("No socket support")
322 if resource == 'gui' and not _is_gui_available():
323 raise ResourceDenied(_is_gui_available.reason)
324
325def _get_kernel_version(sysname="Linux"):
326 import platform

Callers 3

_make_test_fileMethod · 0.90
setUpModuleFunction · 0.90
open_urlresourceFunction · 0.70

Calls 3

is_resource_enabledFunction · 0.85
ResourceDeniedClass · 0.85
_is_gui_availableFunction · 0.85

Tested by 2

_make_test_fileMethod · 0.72
setUpModuleFunction · 0.72