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