'Continously read and parse LDIF records'

def parse(self):

    self._line = self._input_file.readline()
    while (self._line and ((not self._max_entries) or (self.records_read < self._max_entries))):
        version = None
        dn = None
        changetype = None
        modop = None
        entry = {}
        (attr_type, attr_value) = self._parseAttrTypeandValue()
        while ((attr_type != None) and (attr_value != None)):
            if (attr_type == 'dn'):
                if (dn != None):
                    raise ValueError, 'Two    lines    starting    with    dn:    in    one    record.'
                if (not is_dn(attr_value)):
                    raise ValueError, ('No    valid    string-representation    of    distinguished    name    %s.' % repr(attr_value))
                dn = attr_value
            elif ((attr_type == 'version') and (dn is None)):
                version = 1
            elif (attr_type == 'changetype'):
                if (dn is None):
                    raise ValueError, 'Read    changetype:    before    getting    valid    dn:    line.'
                if (changetype != None):
                    raise ValueError, 'Two    lines    starting    with    changetype:    in    one    record.'
                if (not valid_changetype_dict.has_key(attr_value)):
                    raise ValueError, ('changetype    value    %s    is    invalid.' % repr(attr_value))
                changetype = attr_value
            elif ((attr_value != None) and (not self._ignored_attr_types.has_key(attr_type.lower()))):
                if entry.has_key(attr_type):
                    entry[attr_type].append(attr_value)
                else:
                    entry[attr_type] = [attr_value]
            (attr_type, attr_value) = self._parseAttrTypeandValue()
        if entry:
            self.handle(dn, entry)
            self.records_read = (self.records_read + 1)
    return
