/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Model/table.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/Model/table.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 765 by bh, Tue Apr 29 12:42:14 2003 UTC revision 806 by jan, Fri May 2 16:43:59 2003 UTC
# Line 1  Line 1 
1  # Copyright (c) 2001, 2002, 2003 by Intevation GmbH  # Copyright (c) 2001, 2002, 2003 by Intevation GmbH
2  # Authors:  # Authors:
3  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
4    # Jan-Oliver Wagner <[email protected]>
5  #  #
6  # This program is free software under the GPL (>=v2)  # This program is free software under the GPL (>=v2)
7  # Read the file COPYING coming with Thuban for details.  # Read the file COPYING coming with Thuban for details.
# Line 24  dbflib_fieldtypes = {dbflib.FTString: FI Line 25  dbflib_fieldtypes = {dbflib.FTString: FI
25                       dbflib.FTInteger: FIELDTYPE_INT,                       dbflib.FTInteger: FIELDTYPE_INT,
26                       dbflib.FTDouble: FIELDTYPE_DOUBLE}                       dbflib.FTDouble: FIELDTYPE_DOUBLE}
27    
28    class MemoryTable:
29    
30        """Quite simple table implementation that operates on a list of tuples.
31        All of the data are kept in the memory."""
32    
33        def __init__(self, fields, data):
34            """Initialize the MemoryTable
35    
36            Parameters:
37            fields -- List of (name, field_type) pairs
38            data -- List of tuples, one for each row of data
39            """
40            self.fields = fields
41            self.data = data
42    
43        def field_count(self):
44            return len(self.fields)
45    
46        def field_info(self, index):
47            name, type = self.fields[index]
48            return (type, name)
49    
50        def record_count(self):
51            return len(self.data)
52    
53        def read_record(self, index):
54            return dict([(self.fields[i][0], self.data[index][i])
55                          for i in range(len(self.fields))])
56    
57        def write_record(self, record, values):
58            # TODO: Check for correct lenght and perhaps also
59            # for correct types in case values is a tuple. How to report problems?
60            # TODO: Allow values to be a dictionary and write the single
61            # fields that are specified.
62            self.data[record] = values
63    
64    
65  class DBFTable:  class DBFTable:
66    
67      """      """

Legend:
Removed from v.765  
changed lines
  Added in v.806

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26