1 |
# Copyright (c) 2001 by Intevation GmbH |
# Copyright (c) 2001, 2002 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
4 |
# |
# |
36 |
self.filename = filename |
self.filename = filename |
37 |
self.dbf = dbflib.DBFFile(filename) |
self.dbf = dbflib.DBFFile(filename) |
38 |
|
|
39 |
|
def Destroy(self): |
40 |
|
self.dbf.close() |
41 |
|
self.dbf = None |
42 |
|
|
43 |
def record_count(self): |
def record_count(self): |
44 |
"""Return the number of records""" |
"""Return the number of records""" |
45 |
return self.dbf.record_count() |
return self.dbf.record_count() |
63 |
""" |
""" |
64 |
return self.dbf.read_record(record) |
return self.dbf.read_record(record) |
65 |
|
|
66 |
|
def write_record(self, record, values): |
67 |
|
"""Write the values into the record |
68 |
|
|
69 |
|
The values parameter may either be a dictionary or a sequence. |
70 |
|
|
71 |
|
If it's a dictionary the keys must be the names of the fields |
72 |
|
and their value must have a suitable type. Only the fields |
73 |
|
actually contained in the dictionary are written. Fields for |
74 |
|
which there's no item in the dict are not modified. |
75 |
|
|
76 |
|
If it's a sequence, all fields must be present in the right |
77 |
|
order. |
78 |
|
""" |
79 |
|
writable_dbf = dbflib.DBFFile(self.filename, "r+b") |
80 |
|
writable_dbf.write_record(record, values) |
81 |
|
writable_dbf.close() |