1.1 --- a/simplex/__init__.py Sun Oct 02 16:32:41 2011 +0200
1.2 +++ b/simplex/__init__.py Sun Oct 02 17:25:31 2011 +0200
1.3 @@ -31,13 +31,13 @@
1.4 from simplex.readers import *
1.5 import bisect
1.6
1.7 -def make_index(reader, accessor, interval):
1.8 +def make_index(reader, get_key, interval):
1.9
1.10 """
1.11 - Index a resource whose 'reader' provides records and whose 'accessor' can
1.12 - yield the key for such records, creating an index entry for a record after a
1.13 - given number of records, defined by 'interval', have been read since the
1.14 - last entry was produced.
1.15 + Index a resource whose 'reader' provides records, using a 'get_key'
1.16 + operation to yield the key for such records, creating an index entry for a
1.17 + record after a given number of records, defined by 'interval', have been
1.18 + read since the last entry was produced.
1.19 """
1.20
1.21 l = []
1.22 @@ -47,7 +47,7 @@
1.23 start_pos = 0
1.24
1.25 for i, record in enumerate(reader):
1.26 - key = accessor.get_key(record)
1.27 + key = get_key(record)
1.28
1.29 # Where duplicate keys are permitted, the first record employing the key
1.30 # must be available as an index entry. Otherwise, records preceding the
1.31 @@ -65,12 +65,12 @@
1.32
1.33 return l
1.34
1.35 -def find_with_index(reader, accessor, l, term):
1.36 +def find_with_index(reader, get_key, l, term):
1.37
1.38 """
1.39 - Find in the resource whose 'reader' provides records and whose 'accessor'
1.40 - can yield the key for such records, using the given index list 'l', the
1.41 - given 'term', returning a record employing the term or None if no such
1.42 + In the resource whose 'reader' provides records, using a 'get_key' operation
1.43 + to yield the key for such records, and using the given index list 'l', find
1.44 + the given 'term', returning a record employing the term or None if no such
1.45 record was found.
1.46 """
1.47
1.48 @@ -90,18 +90,18 @@
1.49 found, pos = l[i]
1.50
1.51 reader.seek(pos)
1.52 - return find_in_file(reader, accessor, term)
1.53 + return find_in_file(reader, get_key, term)
1.54
1.55 -def find_in_file(reader, accessor, term):
1.56 +def find_in_file(reader, get_key, term):
1.57
1.58 """
1.59 - Find in the resource whose 'reader' provides records and whose 'accessor'
1.60 - can yield the key for such records, the given 'term', returning a record
1.61 + In the resource whose 'reader' provides records, using a 'get_key' operation
1.62 + to yield the key for such records, find the given 'term', returning a record
1.63 employing the term or None if no such record was found.
1.64 """
1.65
1.66 for record in reader:
1.67 - key = accessor.get_key(record)
1.68 + key = get_key(record)
1.69 if term == key:
1.70 return record
1.71