(category)
| 250 | |
| 251 | # Helper for _setoption() |
| 252 | def _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 | |
| 273 | def _is_internal_frame(frame): |
no test coverage detected