(arg)
| 212 | |
| 213 | # Helper for _processoptions() |
| 214 | def _setoption(arg): |
| 215 | parts = arg.split(':') |
| 216 | if len(parts) > 5: |
| 217 | raise _OptionError("too many fields (max 5): %r" % (arg,)) |
| 218 | while len(parts) < 5: |
| 219 | parts.append('') |
| 220 | action, message, category, module, lineno = [s.strip() |
| 221 | for s in parts] |
| 222 | action = _getaction(action) |
| 223 | category = _getcategory(category) |
| 224 | if message or module: |
| 225 | import re |
| 226 | if message: |
| 227 | message = re.escape(message) |
| 228 | if module: |
| 229 | module = re.escape(module) + r'\Z' |
| 230 | if lineno: |
| 231 | try: |
| 232 | lineno = int(lineno) |
| 233 | if lineno < 0: |
| 234 | raise ValueError |
| 235 | except (ValueError, OverflowError): |
| 236 | raise _OptionError("invalid lineno %r" % (lineno,)) from None |
| 237 | else: |
| 238 | lineno = 0 |
| 239 | filterwarnings(action, message, category, module, lineno) |
| 240 | |
| 241 | # Helper for _setoption() |
| 242 | def _getaction(action): |
no test coverage detected