1.1 --- a/simplex/readers.py Sun Oct 02 17:40:02 2011 +0200
1.2 +++ b/simplex/readers.py Sun Oct 02 19:52:30 2011 +0200
1.3 @@ -20,7 +20,10 @@
1.4
1.5 class TextFile:
1.6
1.7 - "A wrapper around text files."
1.8 + """
1.9 + An example wrapper around text files, mostly duplicating the facilities of
1.10 + file objects itself.
1.11 + """
1.12
1.13 def __init__(self, f):
1.14 self.f = f
2.1 --- a/test_indexed.py Sun Oct 02 17:40:02 2011 +0200
2.2 +++ b/test_indexed.py Sun Oct 02 19:52:30 2011 +0200
2.3 @@ -13,18 +13,17 @@
2.4 sys.exit(1)
2.5
2.6 f = open(filename)
2.7 -reader = TextFile(f)
2.8 accessor = DelimitedRecord(fields, numeric=(numeric == "true"))
2.9 try:
2.10 t = time.time()
2.11 - l = make_index(reader, accessor.get_key, int(interval))
2.12 + l = make_index(f, accessor.get_key, int(interval))
2.13 print "Indexed in %s seconds." % (time.time() - t)
2.14
2.15 # Now use the index.
2.16
2.17 for term in terms:
2.18 t = time.time()
2.19 - line = find_with_index(reader, accessor.get_key, l, accessor.convert(term))
2.20 + line = find_with_index(f, accessor.get_key, l, accessor.convert(term))
2.21 if line:
2.22 print "Found (at %s seconds)...\n%s" % (time.time() - t, line)
2.23
3.1 --- a/test_scan.py Sun Oct 02 17:40:02 2011 +0200
3.2 +++ b/test_scan.py Sun Oct 02 19:52:30 2011 +0200
3.3 @@ -13,14 +13,13 @@
3.4 sys.exit(1)
3.5
3.6 f = open(filename)
3.7 -reader = TextFile(f)
3.8 accessor = DelimitedRecord(fields, numeric=(numeric == "true"))
3.9 try:
3.10 for term in terms:
3.11 - reader.seek(0)
3.12 + f.seek(0)
3.13
3.14 t = time.time()
3.15 - line = find_in_file(reader, accessor.get_key, accessor.convert(term))
3.16 + line = find_in_file(f, accessor.get_key, accessor.convert(term))
3.17 if line:
3.18 print "Found (at %s seconds)...\n%s" % (time.time() - t, line)
3.19 finally: