MCPcopy Index your code
hub / github.com/python/cpython / _getcategory

Function _getcategory

Lib/_py_warnings.py:420–438  ·  view source on GitHub ↗
(category)

Source from the content-addressed store, hash-verified

418
419# Helper for _setoption()
420def _getcategory(category):
421 if not category:
422 return Warning
423 if '.' not in category:
424 import builtins as m
425 klass = category
426 else:
427 module, _, klass = category.rpartition('.')
428 try:
429 m = __import__(module, None, None, [klass])
430 except ImportError:
431 raise _wm._OptionError("invalid module name: %r" % (module,)) from None
432 try:
433 cat = getattr(m, klass)
434 except AttributeError:
435 raise _wm._OptionError("unknown warning category: %r" % (category,)) from None
436 if not issubclass(cat, Warning):
437 raise _wm._OptionError("invalid warning category: %r" % (category,))
438 return cat
439
440
441def _is_internal_filename(filename):

Callers

nothing calls this directly

Calls 2

__import__Function · 0.85
rpartitionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…