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

Method _find_options

tools/python-3.11.9-amd64/Lib/doctest.py:749–773  ·  view source on GitHub ↗

Return a dictionary containing option overrides extracted from option directives in the given source string. `name` is the string's name, and `lineno` is the line number where the example starts; both are used for error messages.

(self, source, name, lineno)

Source from the content-addressed store, hash-verified

747 re.MULTILINE)
748
749 def _find_options(self, source, name, lineno):
750 """
751 Return a dictionary containing option overrides extracted from
752 option directives in the given source string.
753
754 `name` is the string's name, and `lineno` is the line number
755 where the example starts; both are used for error messages.
756 """
757 options = {}
758 # (note: with the current regexp, this will match at most once:)
759 for m in self._OPTION_DIRECTIVE_RE.finditer(source):
760 option_strings = m.group(1).replace(',', ' ').split()
761 for option in option_strings:
762 if (option[0] not in '+-' or
763 option[1:] not in OPTIONFLAGS_BY_NAME):
764 raise ValueError('line %r of the doctest for %s '
765 'has an invalid option: %r' %
766 (lineno+1, name, option))
767 flag = OPTIONFLAGS_BY_NAME[option[1:]]
768 options[flag] = (option[0] == '+')
769 if options and self._IS_BLANK_OR_COMMENT(source):
770 raise ValueError('line %r of the doctest for %s has an option '
771 'directive on a line with no example: %r' %
772 (lineno, name, source))
773 return options
774
775 # This regular expression finds the indentation of every non-blank
776 # line in a string.

Callers 1

_parse_exampleMethod · 0.95

Calls 3

splitMethod · 0.45
replaceMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected