Fixed Python 2.6 compatibility issue

Select was using "raise 'No Match'" to break from non-matches, this is
deprecated
This commit is contained in:
ryuslash 2010-04-08 15:12:26 +02:00
parent a567e8630f
commit 9fb2b4ff58

View file

@ -1718,12 +1718,14 @@ class KirbyBase:
while line:
# Strip off newline character and any trailing spaces.
line = line[:-1].strip()
try:
# Keep track of matching
is_no_match = False
# If blank line, skip this record.
if line == "": raise 'No Match'
if line == "": is_no_match = True
# Split the line up into fields.
record = line.split("|", maxfield)
if not is_no_match:
# Foreach correspond field and pattern, check to see
# if the table record's field matches successfully.
for fieldPos, pattern in fieldPos_new_patterns:
@ -1741,10 +1743,12 @@ class KirbyBase:
if not pattern.search(
self._unencodeString(record[fieldPos])
):
raise 'No Match'
is_no_match = True
break
else:
if record[fieldPos] != pattern:
raise 'No Match'
is_no_match = True
break
except Exception:
raise KBError(
'Invalid match expression for %s'
@ -1755,7 +1759,8 @@ class KirbyBase:
# here rather than a boolean compare.
elif self.field_types[fieldPos] == bool:
if record[fieldPos] != pattern:
raise 'No Match'
is_no_match = True
break
# If it is not a string or a boolean, then it must
# be a number or a date.
else:
@ -1791,12 +1796,11 @@ class KirbyBase:
# they are trying to do and I do it directly.
# This sped up queries by 40%.
if not pattern[0](tableValue, pattern[1]):
raise 'No Match'
is_no_match = True
break
# If a 'No Match' exception was raised, then go to the
# next record, otherwise, add it to the list of matches.
except 'No Match':
pass
else:
if not is_no_match:
match_list.append([line, fpos])
# Save the file position BEFORE we read the next record,
# because after a read it is pointing at the END of the