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

Method _find_options

Lib/doctest.py:770–794  ·  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

768 re.MULTILINE)
769
770 def _find_options(self, source, name, lineno):
771 """
772 Return a dictionary containing option overrides extracted from
773 option directives in the given source string.
774
775 `name` is the string's name, and `lineno` is the line number
776 where the example starts; both are used for error messages.
777 """
778 options = {}
779 # (note: with the current regexp, this will match at most once:)
780 for m in self._OPTION_DIRECTIVE_RE.finditer(source):
781 option_strings = m.group(1).replace(',', ' ').split()
782 for option in option_strings:
783 if (option[0] not in '+-' or
784 option[1:] not in OPTIONFLAGS_BY_NAME):
785 raise ValueError('line %r of the doctest for %s '
786 'has an invalid option: %r' %
787 (lineno+1, name, option))
788 flag = OPTIONFLAGS_BY_NAME[option[1:]]
789 options[flag] = (option[0] == '+')
790 if options and self._IS_BLANK_OR_COMMENT(source):
791 raise ValueError('line %r of the doctest for %s has an option '
792 'directive on a line with no example: %r' %
793 (lineno, name, source))
794 return options
795
796 # This regular expression finds the indentation of every non-blank
797 # 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