1 |
# Copyright (c) 2001, 2002 by Intevation GmbH |
# Copyright (c) 2001, 2002, 2003 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
4 |
# |
# |
38 |
# important that Thuban can work with read-only files. Therefore the |
# important that Thuban can work with read-only files. Therefore the |
39 |
# DBF file is opened only for reading initially. Only when |
# DBF file is opened only for reading initially. Only when |
40 |
# write_record is called we try to open the DBF file for writing as |
# write_record is called we try to open the DBF file for writing as |
41 |
# well. If that succeeds the dbf read/write DBF file will be used |
# well. If that succeeds the read/write DBF file will be used for |
42 |
# for all IO afterwards. |
# all IO afterwards. |
43 |
# |
# |
44 |
# It's important to use the same DBF file object for both reading |
# It's important to use the same DBF file object for both reading |
45 |
# and writing to make sure that reading a records after writing |
# and writing to make sure that reading a records after writing |
75 |
type = dbflib_fieldtypes[type] |
type = dbflib_fieldtypes[type] |
76 |
return type, name, width, prec |
return type, name, width, prec |
77 |
|
|
78 |
|
def field_info_by_name(self, fieldName): |
79 |
|
count = self.field_count() |
80 |
|
|
81 |
|
for i in range(count): |
82 |
|
info = self.field_info(i) |
83 |
|
if info[1] == fieldName: |
84 |
|
return info |
85 |
|
|
86 |
|
return None |
87 |
|
|
88 |
def read_record(self, record): |
def read_record(self, record): |
89 |
"""Return the record no. record as a dict mapping field names to values |
"""Return the record no. record as a dict mapping field names to values |
90 |
""" |
""" |
110 |
self._writable = 1 |
self._writable = 1 |
111 |
self.dbf.write_record(record, values) |
self.dbf.write_record(record, values) |
112 |
self.dbf.commit() |
self.dbf.commit() |
113 |
|
|