'Parse a sectioned setup file.
The sections in setup file contains a title line at the top,
indicated by a name in square brackets (`[]\'), plus key/value
options lines, indicated by `name: value\' format lines.
Continuations are represented by an embedded newline then
leading whitespace.  Blank lines, lines beginning with a \'#\',
and just about everything else are ignored.'

def _read(self, fp, fpname):

    cursect = None
    optname = None
    lineno = 0
    e = None
    while True:
        line = fp.readline()
        if (not line):
            break
        lineno = (lineno + 1)
        if ((line.strip() == '') or (line[0] in '#;')):
            continue
        if ((line.split(None, 1)[0].lower() == 'rem') and (line[0] in 'rR')):
            continue
        if (line[0].isspace() and (cursect is not None) and optname):
            value = line.strip()
            if value:
                cursect[optname].append(value)
        else:
            mo = self.SECTCRE.match(line)
            if mo:
                sectname = mo.group('header')
                if (sectname in self._sections):
                    cursect = self._sections[sectname]
                elif (sectname == DEFAULTSECT):
                    cursect = self._defaults
                else:
                    cursect = self._dict()
                    cursect['__name__'] = sectname
                    self._sections[sectname] = cursect
                optname = None
            elif (cursect is None):
                raise MissingSectionHeaderError(fpname, lineno, line)
            else:
                mo = self._optcre.match(line)
                if mo:
                    (optname, vi, optval) = mo.group('option', 'vi', 'value')
                    optname = self.optionxform(optname.rstrip())
                    if (optval is not None):
                        if ((vi in ('=', ':')) and (';' in optval)):
                            pos = optval.find(';')
                            if ((pos != (-1)) and optval[(pos - 1)].isspace()):
                                optval = optval[:pos]
                        optval = optval.strip()
                        if (optval == '""'):
                            optval = ''
                        cursect[optname] = [optval]
                    else:
                        cursect[optname] = optval
                else:
                    if (not e):
                        e = ParsingError(fpname)
                    e.append(lineno, repr(line))
    if e:
        raise e
    all_sections = [self._defaults]
    all_sections.extend(self._sections.values())
    for options in all_sections:
        for (name, val) in options.items():
            if isinstance(val, list):
                options[name] = '\n'.join(val)
