Skip to content

Commit

Permalink
LDIFParser.parse_change_records(): more liberal parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
stroeder committed Jul 17, 2016
1 parent c97fe7f commit cb07289
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions Lib/ldif.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
See http://www.python-ldap.org/ for details.
$Id: ldif.py,v 1.96 2016/07/17 19:30:44 stroeder Exp $
$Id: ldif.py,v 1.97 2016/07/17 19:38:32 stroeder Exp $
Python compability note:
Tested with Python 2.0+, but should work with Python 1.5.2+.
Expand Down Expand Up @@ -487,31 +487,31 @@ def parse_change_records(self):
# From here we assume a change record is read with changetype: modify
modops = []

# Loop for reading the list of modifications
while k!=None:
# Extract attribute mod-operation (add, delete, replace)
try:
modop = MOD_OP_INTEGER[k]
except KeyError:
raise ValueError('Line %d: Invalid mod-op string: %s' % (self.line_counter,repr(k)))
# we now have the attribute name to be modified
modattr = v
modvalues = []
try:
k,v = next_key_and_value()
except EOFError:
k,v = None,None
while k==modattr:
modvalues.append(v)
k,v = next_key_and_value()
modops.append((modop,modattr,modvalues or None))
try:
try:
# Loop for reading the list of modifications
while k!=None:
# Extract attribute mod-operation (add, delete, replace)
try:
modop = MOD_OP_INTEGER[k]
except KeyError:
raise ValueError('Line %d: Invalid mod-op string: %s' % (self.line_counter,repr(k)))
# we now have the attribute name to be modified
modattr = v
modvalues = []
k,v = next_key_and_value()
except EOFError:
k,v = None,None
if k=='-':
# Consume next line
while k==modattr:
modvalues.append(v)
try:
k,v = next_key_and_value()
except EOFError:
k,v = None,None
modops.append((modop,modattr,modvalues or None))
k,v = next_key_and_value()
if k=='-':
# Consume next line
k,v = next_key_and_value()
except EOFError:
k,v = None,None

if modops:
# append entry to result list
Expand Down

0 comments on commit cb07289

Please sign in to comment.