(self, node)
| 492 | self._add_message(lineno, docstring, is_docstring=True) |
| 493 | |
| 494 | def _extract_message(self, node): |
| 495 | func_name = self._get_func_name(node) |
| 496 | errors = [] |
| 497 | specs = self.options.keywords.get(func_name, []) |
| 498 | for spec in specs: |
| 499 | err = self._extract_message_with_spec(node, spec) |
| 500 | if err is None: |
| 501 | return |
| 502 | errors.append(err) |
| 503 | |
| 504 | if not errors: |
| 505 | return |
| 506 | if len(errors) == 1: |
| 507 | print(f'*** {self.filename}:{node.lineno}: {errors[0]}', |
| 508 | file=sys.stderr) |
| 509 | else: |
| 510 | # There are multiple keyword specs for the function name and |
| 511 | # none of them could be extracted. Print a general error |
| 512 | # message and list the errors for each keyword spec. |
| 513 | print(f'*** {self.filename}:{node.lineno}: ' |
| 514 | f'No keywords matched gettext call "{func_name}":', |
| 515 | file=sys.stderr) |
| 516 | for spec, err in zip(specs, errors, strict=True): |
| 517 | unparsed = unparse_spec(func_name, spec) |
| 518 | print(f'\tkeyword="{unparsed}": {err}', file=sys.stderr) |
| 519 | |
| 520 | def _extract_message_with_spec(self, node, spec): |
| 521 | """Extract a gettext call with the given spec. |
no test coverage detected