MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _getcategory

Function _getcategory

tools/python-3.11.9-amd64/Lib/warnings.py:252–270  ·  view source on GitHub ↗
(category)

Source from the content-addressed store, hash-verified

250
251# Helper for _setoption()
252def _getcategory(category):
253 if not category:
254 return Warning
255 if '.' not in category:
256 import builtins as m
257 klass = category
258 else:
259 module, _, klass = category.rpartition('.')
260 try:
261 m = __import__(module, None, None, [klass])
262 except ImportError:
263 raise _OptionError("invalid module name: %r" % (module,)) from None
264 try:
265 cat = getattr(m, klass)
266 except AttributeError:
267 raise _OptionError("unknown warning category: %r" % (category,)) from None
268 if not issubclass(cat, Warning):
269 raise _OptionError("invalid warning category: %r" % (category,))
270 return cat
271
272
273def _is_internal_frame(frame):

Callers 1

_setoptionFunction · 0.85

Calls 3

__import__Function · 0.85
_OptionErrorClass · 0.85
rpartitionMethod · 0.80

Tested by

no test coverage detected