1.1 --- a/simplex/readers.py Sun Oct 02 17:25:31 2011 +0200
1.2 +++ b/simplex/readers.py Sun Oct 02 17:40:02 2011 +0200
1.3 @@ -35,17 +35,17 @@
1.4
1.5 "An accessor using a delimiter to split a record."
1.6
1.7 - def __init__(self, keys=None, delimiter=None, numeric=0):
1.8 + def __init__(self, fields=None, delimiter=None, numeric=0):
1.9
1.10 """
1.11 - Initialise the accessor using a sequence of 'keys' indicating the
1.12 + Initialise the accessor using a sequence of 'fields' indicating the
1.13 columns in each record that provide the values in the eventual compound
1.14 - key provided by each record, along with a 'delimiter' indicating how
1.15 - such columns are identified. If 'numeric' is set to a true value, keys
1.16 + field provided by each record, along with a 'delimiter' indicating how
1.17 + such columns are identified. If 'numeric' is set to a true value, fields
1.18 will be interpreted as numbers.
1.19 """
1.20
1.21 - self.keys = keys or [0]
1.22 + self.fields = fields or [0]
1.23 self.delimiter = delimiter
1.24 self.convert = numeric and self.convert_numeric or (lambda x: x)
1.25
1.26 @@ -54,6 +54,6 @@
1.27
1.28 def get_key(self, record):
1.29 values = record.split(self.delimiter)
1.30 - return self.convert([values[key] for key in self.keys])
1.31 + return self.convert([values[field] for field in self.fields])
1.32
1.33 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/test_indexed.py Sun Oct 02 17:25:31 2011 +0200
2.2 +++ b/test_indexed.py Sun Oct 02 17:40:02 2011 +0200
2.3 @@ -6,15 +6,15 @@
2.4 try:
2.5 separator = sys.argv.index("--")
2.6 filename, numeric, interval = sys.argv[1:4]
2.7 - keys = map(int, sys.argv[4:separator])
2.8 - terms = groups(sys.argv[separator+1:], len(keys))
2.9 + fields = map(int, sys.argv[4:separator])
2.10 + terms = groups(sys.argv[separator+1:], len(fields))
2.11 except (IndexError, ValueError):
2.12 - print >>sys.stderr, "Usage: %s <filename> <interval> <key>... -- <term value>..." % sys.argv[0]
2.13 + print >>sys.stderr, "Usage: %s <filename> <interval> <field>... -- <term value>..." % sys.argv[0]
2.14 sys.exit(1)
2.15
2.16 f = open(filename)
2.17 reader = TextFile(f)
2.18 -accessor = DelimitedRecord(keys, numeric=(numeric == "true"))
2.19 +accessor = DelimitedRecord(fields, numeric=(numeric == "true"))
2.20 try:
2.21 t = time.time()
2.22 l = make_index(reader, accessor.get_key, int(interval))
3.1 --- a/test_scan.py Sun Oct 02 17:25:31 2011 +0200
3.2 +++ b/test_scan.py Sun Oct 02 17:40:02 2011 +0200
3.3 @@ -6,15 +6,15 @@
3.4 try:
3.5 separator = sys.argv.index("--")
3.6 filename, numeric = sys.argv[1:3]
3.7 - keys = map(int, sys.argv[3:separator])
3.8 - terms = groups(sys.argv[separator+1:], len(keys))
3.9 + fields = map(int, sys.argv[3:separator])
3.10 + terms = groups(sys.argv[separator+1:], len(fields))
3.11 except (IndexError, ValueError):
3.12 - print >>sys.stderr, "Usage: %s <filename> <key>... -- <term value>..." % sys.argv[0]
3.13 + print >>sys.stderr, "Usage: %s <filename> <field>... -- <term value>..." % sys.argv[0]
3.14 sys.exit(1)
3.15
3.16 f = open(filename)
3.17 reader = TextFile(f)
3.18 -accessor = DelimitedRecord(keys, numeric=(numeric == "true"))
3.19 +accessor = DelimitedRecord(fields, numeric=(numeric == "true"))
3.20 try:
3.21 for term in terms:
3.22 reader.seek(0)