Read from file.

        Parameters
        ----------
        section : string
            Section.
        option : string
            Option.

        Returns
        -------
        string
            Value.
499880
def read(self, section, option):
        
        self.config.read(self.filepath)
        raw = self.config.get(section, option)
        out = tidy_headers._parse_item.string2item(raw, sep=", ")
        return out
963020
def _read_config(filename):
    
    parser = configparser.RawConfigParser()
    if filename and not parser.read(filename):
        sys.stderr.write("Unable to open configuration file %s. Use --config='' to disable this warning.\n" % filename)

    config = {}

    for section, defaults in BASE_CONFIG.items():
        # Patterns are handled separately
        if section == 'patterns':
            continue

        for name, descr in defaults.items():
            kind, default = descr
            if section in parser.sections() and name in parser.options(section):
                if kind == 'int':
                    value = parser.getint(section, name)
                elif kind == 'float':
                    value = parser.getfloat(section, name)
                elif kind == 'bool':
                    value = parser.getboolean(section, name)
                else:
                    value = parser.get(section, name)
            else:
                value = default
            config[name] = value

    if 'patterns' in parser.sections():
        patterns = [parser.get('patterns', opt) for opt in parser.options('patterns')]
    else:
        patterns = DEFAULT_PATTERNS
    config['patterns'] = patterns

    return config
1273469
def display_string_dump(self, section_spec):
        
        section = _section_from_spec(self.elf_file, section_spec)
        if section is None:
            print("Section '%s' does not exist in the file!" % section_spec)
            return None

        data = section.data()
        dataptr = 0

        strs = []
        while dataptr < len(data):
            while dataptr < len(data) and not 32 <= byte2int(data[dataptr]) <= 127:
                dataptr += 1

            if dataptr >= len(data):
                break

            endptr = dataptr
            while endptr < len(data) and byte2int(data[endptr]) != 0:
                endptr += 1

            strs.append(binascii.b2a_hex(
                data[dataptr:endptr]).decode().upper())
            dataptr = endptr

        return strs
233329
def parse_section(self, section_options):
        
        for (name, (_, value)) in section_options.items():
            try:
                self[name] = value

            except KeyError:
                pass
493370
def read_whole_file(self):
        
        chunk = None
        with open(self.path, 'rb') as infile:
            chunk = infile.read()
        return chunk
1103519
def get_section_config(self, section):
        

        if section not in self._config:
            return self._config["DEFAULT"]
        return self._config[section]
67794
def get_options(self, section='default', opt_keys=None, vars=None):
        
        vars = vars if vars else self.default_vars
        conf = self.parser
        opts = {}
        if opt_keys is None:
            if conf is None:
                opt_keys = {}
            else:
                if not self.robust or conf.has_section(section):
                    opt_keys = conf.options(section)
                else:
                    opt_keys = {}
        else:
            logger.debug('conf: %s' % conf)
            copts = conf.options(section) if conf else {}
            opt_keys = set(opt_keys).intersection(set(copts))
        for option in opt_keys:
            logger.debug(f'option: {option}, vars: {vars}')
            opts[option] = conf.get(section, option, vars=vars)
        return opts
1091087
def from_file(filename, section='matrix'):
    
    config = parse_config(open(filename), section=section)
    return from_config(config)
611975
def load(self, file_parser, section_name):
        
        self._load(file_parser, section_name)
        self.post_load()
949876
def read_stream (stream):
    """"""

    section = None
    key = None
    data = None

    for fullline in stream:
        line = fullline.split ('#', 1)[0]

        m = sectionre.match (line)
        if m is not None:
            # New section
            if section is not None:
                if key is not None:
                    section.set_one (key, data.strip ().decode ('utf8'))
                    key = data = None
                yield section

            section = Holder ()
            section.section = m.group (1)
            continue

        if len (line.strip ()) == 0:
            if key is not None:
                section.set_one (key, data.strip ().decode ('utf8'))
                key = data = None
            continue

        m = escre.match (fullline)
        if m is not None:
            if section is None:
                raise InifileError ('key seen without section!')
            if key is not None:
                section.set_one (key, data.strip ().decode ('utf8'))
            key = m.group (1)
            data = m.group (2).replace (r'\"', '"').replace (r'\n', '\n').replace (r'\\', '\\')
            section.set_one (key, data.decode ('utf8'))
            key = data = None
            continue

        m = keyre.match (line)
        if m is not None:
            if section is None:
                raise InifileError ('key seen without section!')
            if key is not None:
                section.set_one (key, data.strip ().decode ('utf8'))
            key = m.group (1)
            data = m.group (2)
            if not len (data):
                data = ' '
            elif not data[-1].isspace ():
                data += ' '
            continue

        if line[0].isspace () and key is not None:
            data += line.strip () + ' '
            continue

        raise InifileError ('unparsable line: ' + line[:-1])

    if section is not None:
        if key is not None:
            section.set_one (key, data.strip ().decode ('utf8'))
        yield section
63018
def getfile(self, section, option, raw=False, vars=None, fallback="", validate=False):
        
        v = self.get(section, option, raw=raw, vars=vars, fallback=fallback)
        v = self._convert_to_path(v)
        return v if not validate or os.path.isfile(v) else fallback
746492
def save_option(self, path, section, option, value):
        
        config = ConfigParser.SafeConfigParser()
        config.read(path)
        if not config.has_section(section):
            config.add_section(section)
        config.set(section, option, value)
        fp = open(path, 'w')
        config.write(fp)
        fp.close()
        if not self.has_section(section):
            self.add_section(section)
        self.set(section, option, value)
580845
def _get_section(self, name, type):
        
        for section in self.sections:
            if section['name'] == name and section['type'] == type:
                return section
        return None
391111
def read_text_from_file(path: str) -> str:
    
    with open(path) as text_file:
        content = text_file.read()

    return content
740705
def read_sections(self, sections_file, get_goids_only, exclude_ungrouped):
        """"""
        ext = os.path.splitext(sections_file)[1]
        file_contents = None
        if ext == '.py':
            file_contents = self.read_py(sections_file, get_goids_only, exclude_ungrouped)
        else:
            file_contents = self.read_txt(sections_file, get_goids_only, exclude_ungrouped)
        if file_contents:
            return file_contents.get('sections', None)
1288123
def read(parts):
    
    cur_dir = os.path.abspath(os.path.dirname(__file__))
    with codecs.open(os.path.join(cur_dir, *parts), "rb", "utf-8") as f:
        return f.read()
1322600
def _read_section(self):
        """"""
        lines = [self._last[self._last.find(":")+1:]]
        self._last = self._f.readline()
        while len(self._last) > 0 and len(self._last[0].strip()) == 0:
            lines.append(self._last)
            self._last = self._f.readline()
        return lines