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

Class RawConfigParser

Lib/configparser.py:606–1254  ·  view source on GitHub ↗

ConfigParser that does not do interpolation.

Source from the content-addressed store, hash-verified

604
605
606class RawConfigParser(MutableMapping):
607 """ConfigParser that does not do interpolation."""
608
609 # Regular expressions for parsing section headers and options
610 _SECT_TMPL = r"""
611 \[ # [
612 (?P<header>.+) # very permissive!
613 \] # ]
614 """
615 _OPT_TMPL = r"""
616 (?P<option>.*?) # very permissive!
617 \s*(?P<vi>{delim})\s* # any number of space/tab,
618 # followed by any of the
619 # allowed delimiters,
620 # followed by any space/tab
621 (?P<value>.*)$ # everything up to eol
622 """
623 _OPT_NV_TMPL = r"""
624 (?P<option>.*?) # very permissive!
625 \s*(?: # any number of space/tab,
626 (?P<vi>{delim})\s* # optionally followed by
627 # any of the allowed
628 # delimiters, followed by any
629 # space/tab
630 (?P<value>.*))?$ # everything up to eol
631 """
632 # Interpolation algorithm to be used if the user does not specify another
633 _DEFAULT_INTERPOLATION = Interpolation()
634 # Compiled regular expression for matching sections
635 SECTCRE = re.compile(_SECT_TMPL, re.VERBOSE)
636 # Compiled regular expression for matching options with typical separators
637 OPTCRE = re.compile(_OPT_TMPL.format(delim="=|:"), re.VERBOSE)
638 # Compiled regular expression for matching options with optional values
639 # delimited using typical separators
640 OPTCRE_NV = re.compile(_OPT_NV_TMPL.format(delim="=|:"), re.VERBOSE)
641 # Compiled regular expression for matching leading whitespace in a line
642 NONSPACECRE = re.compile(r"\S")
643 # Possible boolean values in the configuration.
644 BOOLEAN_STATES = {'1': True, 'yes': True, 'true': True, 'on': True,
645 '0': False, 'no': False, 'false': False, 'off': False}
646
647 def __init__(self, defaults=None, dict_type=_default_dict,
648 allow_no_value=False, *, delimiters=('=', ':'),
649 comment_prefixes=('#', ';'), inline_comment_prefixes=None,
650 strict=True, empty_lines_in_values=True,
651 default_section=DEFAULTSECT,
652 interpolation=_UNSET, converters=_UNSET,
653 allow_unnamed_section=False,):
654
655 self._dict = dict_type
656 self._sections = self._dict()
657 self._defaults = self._dict()
658 self._converters = ConverterMapping(self)
659 self._proxies = self._dict()
660 self._proxies[default_section] = SectionProxy(self, default_section)
661 self._delimiters = tuple(delimiters)
662 if delimiters == ('=', ':'):
663 self._optcre = self.OPTCRE_NV if allow_no_value else self.OPTCRE

Callers

nothing calls this directly

Calls 3

InterpolationClass · 0.85
compileMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…