Lines Matching refs:option
41 When `strict` is True, the parser won't allow for any section or option
46 marks the end of an option. Otherwise, internal empty lines of
47 a multiline option are kept as part of the value.
59 instance. It will be used as the handler for option value
77 has_option(section, option)
78 Return whether the given option exists in the given section.
103 get(section, option, raw=False, vars=None, fallback=_UNSET)
104 Return a string value for the named option. All % interpolations are
108 contents override any pre-existing defaults. If `option` is a key in
124 each option in the section. Otherwise, return a list of tuples with
130 remove_option(section, option)
131 Remove the given option from the given section.
133 set(section, option, value)
134 Set the given option.
183 """Raised when no section matches a requested option."""
218 """Raised by strict parsers when an option is repeated in an input source.
220 Current implementation raises this exception only when an option is found
224 def __init__(self, section, option, source=None, lineno=None):
225 msg = [repr(option), " in section ", repr(section),
231 message.append(": option ")
238 self.option = option
241 self.args = (section, option, source, lineno)
245 """A requested option was not found."""
247 def __init__(self, option, section):
248 Error.__init__(self, "No option %r in section: %r" %
249 (option, section))
250 self.option = option
252 self.args = (option, section)
258 def __init__(self, option, section, msg):
260 self.option = option
262 self.args = (option, section, msg)
268 def __init__(self, option, section, rawval, reference):
269 msg = ("Bad value substitution: option {!r} in section {!r} contains "
270 "an interpolation key {!r} which is not a valid option name. "
271 "Raw value: {!r}".format(option, section, reference, rawval))
272 InterpolationError.__init__(self, option, section, msg)
274 self.args = (option, section, rawval, reference)
288 def __init__(self, option, section, rawval):
289 msg = ("Recursion limit exceeded in value substitution: option {!r} "
292 "".format(option, section, MAX_INTERPOLATION_DEPTH,
294 InterpolationError.__init__(self, option, section, msg)
295 self.args = (option, section, rawval)
356 # option is not found it to raise an exception. Created to enable `None` as
364 def before_get(self, parser, section, option, value, defaults):
367 def before_set(self, parser, section, option, value):
370 def before_read(self, parser, section, option, value):
373 def before_write(self, parser, section, option, value):
380 The option values can contain format strings which refer to other values in
394 def before_get(self, parser, section, option, value, defaults):
396 self._interpolate_some(parser, option, L, value, section, defaults, 1)
399 def before_set(self, parser, section, option, value):
407 def _interpolate_some(self, parser, option, accum, rest, section, map,
409 rawval = parser.get(section, option, raw=True, fallback=rest)
411 raise InterpolationDepthError(option, section, rawval)
428 raise InterpolationSyntaxError(option, section,
436 option, section, rawval, var) from None
438 self._interpolate_some(parser, option, accum, v,
444 option, section,
455 def before_get(self, parser, section, option, value, defaults):
457 self._interpolate_some(parser, option, L, value, section, defaults, 1)
460 def before_set(self, parser, section, option, value):
468 def _interpolate_some(self, parser, option, accum, rest, section, map,
470 rawval = parser.get(section, option, raw=True, fallback=rest)
472 raise InterpolationDepthError(option, section, rawval)
489 raise InterpolationSyntaxError(option, section,
494 opt = option
505 option, section,
509 option, section, rawval, ":".join(path)) from None
518 option, section,
538 def before_get(self, parser, section, option, value, vars):
551 option, section, rawval, e.args[0]) from None
555 raise InterpolationDepthError(option, section, rawval)
558 def before_set(self, parser, section, option, value):
580 (?P<option>.*?) # very permissive!
588 (?P<option>.*?) # very permissive!
686 """Return a list of option names for the given section name."""
749 reading, including section names, option names and keys.
781 def get(self, section, option, *, raw=False, vars=None, fallback=_UNSET):
782 """Get an option value for a given section.
784 If `vars` is provided, it must be a dictionary. The option is looked up
803 option = self.optionxform(option)
805 value = d[option]
808 raise NoOptionError(option, section)
815 return self._interpolation.before_get(self, section, option, value,
818 def _get(self, section, conv, option, **kwargs):
819 return conv(self.get(section, option, **kwargs))
821 def _get_conv(self, section, option, conv, *, raw=False, vars=None,
824 return self._get(section, conv, option, raw=raw, vars=vars,
832 def getint(self, section, option, *, raw=False, vars=None,
834 return self._get_conv(section, option, int, raw=raw, vars=vars,
837 def getfloat(self, section, option, *, raw=False, vars=None,
839 return self._get_conv(section, option, float, raw=raw, vars=vars,
842 def getboolean(self, section, option, *, raw=False, vars=None,
844 return self._get_conv(section, option, self._convert_to_boolean,
848 """Return a list of (name, value) tuples for each option in a section.
871 value_getter = lambda option: self._interpolation.before_get(self,
872 section, option, d[option], d)
874 value_getter = lambda option: d[option]
875 return [(option, value_getter(option)) for option in orig_keys]
893 def has_option(self, section, option):
894 """Check for the existence of a given option in a given section.
898 option = self.optionxform(option)
899 return option in self._defaults
903 option = self.optionxform(option)
904 return (option in self._sections[section]
905 or option in self._defaults)
907 def set(self, section, option, value=None):
908 """Set an option."""
910 value = self._interpolation.before_set(self, section, option,
919 sectdict[self.optionxform(option)] = value
954 def remove_option(self, section, option):
955 """Remove an option."""
963 option = self.optionxform(option)
964 existed = option in sectdict
966 del sectdict[option]
1077 # a section header or option header?
1102 # an option line?
1106 optname, vi, optval = mo.group('option', 'vi', 'value')
1121 # valueless option handling
1185 def _validate_value_types(self, *, section="", option="", value=""):
1200 if not isinstance(option, str):
1201 raise TypeError("option keys must be strings")
1204 raise TypeError("option values must be strings")
1216 def set(self, section, option, value=None):
1217 """Set an option. Extends RawConfigParser.set by validating type and
1219 self._validate_value_types(option=option, value=value)
1220 super().set(section, option, value)
1277 self._parser._validate_value_types(option=key, value=value)
1310 def get(self, option, fallback=None, *, raw=False, vars=None,
1312 """Get an option value.
1314 Unless `fallback` is provided, `None` will be returned if the option
1322 return _impl(self._name, option, raw=raw, vars=vars,