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

Method _handle_option

Lib/configparser.py:1144–1173  ·  view source on GitHub ↗
(self, st, line, fpname)

Source from the content-addressed store, hash-verified

1142 st.optname = None
1143
1144 def _handle_option(self, st, line, fpname):
1145 # an option line?
1146 st.indent_level = st.cur_indent_level
1147
1148 mo = self._optcre.match(line.clean)
1149 if not mo:
1150 # a non-fatal parsing error occurred. set up the
1151 # exception but keep going. the exception will be
1152 # raised at the end of the file and will contain a
1153 # list of all bogus lines
1154 st.errors.append(ParsingError(fpname, st.lineno, line))
1155 return
1156
1157 st.optname, vi, optval = mo.group('option', 'vi', 'value')
1158 if not st.optname:
1159 st.errors.append(ParsingError(fpname, st.lineno, line))
1160 st.optname = self.optionxform(st.optname.rstrip())
1161 if (self._strict and
1162 (st.sectname, st.optname) in st.elements_added):
1163 raise DuplicateOptionError(st.sectname, st.optname,
1164 fpname, st.lineno)
1165 st.elements_added.add((st.sectname, st.optname))
1166 # This check is fine because the OPTCRE cannot
1167 # match if it would set optval to None
1168 if optval is not None:
1169 optval = optval.strip()
1170 st.cursect[st.optname] = [optval]
1171 else:
1172 # valueless option handling
1173 st.cursect[st.optname] = None
1174
1175 def _join_multiline_values(self):
1176 defaults = self.default_section, self._defaults

Callers 1

_handle_restMethod · 0.95

Calls 9

optionxformMethod · 0.95
ParsingErrorClass · 0.85
matchMethod · 0.45
appendMethod · 0.45
groupMethod · 0.45
rstripMethod · 0.45
addMethod · 0.45
stripMethod · 0.45

Tested by

no test coverage detected