MCPcopy Index your code
hub / github.com/RustPython/RustPython / _find_options

Method _find_options

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

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

Callers 1

_parse_exampleMethod · 0.95

Calls 4

finditerMethod · 0.80
splitMethod · 0.45
replaceMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected