1 # This file was automatically generated by SWIG (http://www.swig.org).
4 # Don't modify this file, modify the SWIG interface instead.
7 TDB is a simple key-value database similar to GDBM that supports multiple writers.
12 new_instancemethod
= new
.instancemethod
14 _swig_property
= property
16 pass # Python < 2.2 doesn't have 'property'.
17 def _swig_setattr_nondynamic(self
,class_type
,name
,value
,static
=1):
18 if (name
== "thisown"): return self
.this
.own(value
)
20 if type(value
).__name
__ == 'PySwigObject':
21 self
.__dict
__[name
] = value
23 method
= class_type
.__swig
_setmethods
__.get(name
,None)
24 if method
: return method(self
,value
)
25 if (not static
) or hasattr(self
,name
):
26 self
.__dict
__[name
] = value
28 raise AttributeError("You cannot add attributes to %s" % self
)
30 def _swig_setattr(self
,class_type
,name
,value
):
31 return _swig_setattr_nondynamic(self
,class_type
,name
,value
,0)
33 def _swig_getattr(self
,class_type
,name
):
34 if (name
== "thisown"): return self
.this
.own()
35 method
= class_type
.__swig
_getmethods
__.get(name
,None)
36 if method
: return method(self
)
37 raise AttributeError,name
40 try: strthis
= "proxy of " + self
.this
.__repr
__()
42 return "<%s.%s; %s >" % (self
.__class
__.__module
__, self
.__class
__.__name
__, strthis
,)
46 _object
= types
.ObjectType
48 except AttributeError:
54 def _swig_setattr_nondynamic_method(set):
55 def set_attr(self
,name
,value
):
56 if (name
== "thisown"): return self
.this
.own(value
)
57 if hasattr(self
,name
) or (name
== "this"):
60 raise AttributeError("You cannot add attributes to %s" % self
)
64 REPLACE
= _tdb
.REPLACE
67 DEFAULT
= _tdb
.DEFAULT
68 CLEAR_IF_FIRST
= _tdb
.CLEAR_IF_FIRST
69 INTERNAL
= _tdb
.INTERNAL
72 CONVERT
= _tdb
.CONVERT
73 BIGENDIAN
= _tdb
.BIGENDIAN
74 TDB_SUCCESS
= _tdb
.TDB_SUCCESS
75 TDB_ERR_CORRUPT
= _tdb
.TDB_ERR_CORRUPT
76 TDB_ERR_IO
= _tdb
.TDB_ERR_IO
77 TDB_ERR_LOCK
= _tdb
.TDB_ERR_LOCK
78 TDB_ERR_OOM
= _tdb
.TDB_ERR_OOM
79 TDB_ERR_EXISTS
= _tdb
.TDB_ERR_EXISTS
80 TDB_ERR_NOLOCK
= _tdb
.TDB_ERR_NOLOCK
81 TDB_ERR_LOCK_TIMEOUT
= _tdb
.TDB_ERR_LOCK_TIMEOUT
82 TDB_ERR_NOEXIST
= _tdb
.TDB_ERR_NOEXIST
83 TDB_ERR_EINVAL
= _tdb
.TDB_ERR_EINVAL
84 TDB_ERR_RDONLY
= _tdb
.TDB_ERR_RDONLY
87 thisown
= _swig_property(lambda x
: x
.this
.own(), lambda x
, v
: x
.this
.own(v
), doc
='The membership flag')
89 def __init__(self
, *args
, **kwargs
):
91 S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600)
94 _tdb
.Tdb_swiginit(self
,_tdb
.new_Tdb(*args
, **kwargs
))
95 def error(*args
, **kwargs
):
98 Find last error number returned by operation on this TDB.
100 return _tdb
.Tdb_error(*args
, **kwargs
)
102 __swig_destroy__
= _tdb
.delete_Tdb
103 def close(*args
, **kwargs
):
108 return _tdb
.Tdb_close(*args
, **kwargs
)
110 def errorstr(*args
, **kwargs
):
112 S.errorstr() -> errorstring
113 Obtain last error message.
115 return _tdb
.Tdb_errorstr(*args
, **kwargs
)
117 def get(*args
, **kwargs
):
119 S.fetch(key) -> value
122 return _tdb
.Tdb_get(*args
, **kwargs
)
124 def delete(*args
, **kwargs
):
126 S.delete(key) -> None
129 return _tdb
.Tdb_delete(*args
, **kwargs
)
131 def store(*args
, **kwargs
):
133 S.store(key, value, flag=TDB_REPLACE) -> None
136 return _tdb
.Tdb_store(*args
, **kwargs
)
138 def exists(*args
, **kwargs
):
140 S.exists(key) -> bool
141 Check whether key exists in this database.
143 return _tdb
.Tdb_exists(*args
, **kwargs
)
145 def firstkey(*args
, **kwargs
):
148 Return the first key in this database.
150 return _tdb
.Tdb_firstkey(*args
, **kwargs
)
152 def nextkey(*args
, **kwargs
):
154 S.nextkey(prev) -> data
155 Return the next key in this database.
157 return _tdb
.Tdb_nextkey(*args
, **kwargs
)
159 def lock_all(*args
, **kwargs
):
160 """S.lockall() -> bool"""
161 return _tdb
.Tdb_lock_all(*args
, **kwargs
)
163 def unlock_all(*args
, **kwargs
):
164 """S.unlockall() -> bool"""
165 return _tdb
.Tdb_unlock_all(*args
, **kwargs
)
167 def reopen(*args
, **kwargs
):
172 return _tdb
.Tdb_reopen(*args
, **kwargs
)
174 def transaction_start(*args
, **kwargs
):
176 S.transaction_start() -> None
177 Start a new transaction.
179 return _tdb
.Tdb_transaction_start(*args
, **kwargs
)
181 def transaction_commit(*args
, **kwargs
):
183 S.transaction_commit() -> None
184 Commit the currently active transaction.
186 return _tdb
.Tdb_transaction_commit(*args
, **kwargs
)
188 def transaction_cancel(*args
, **kwargs
):
190 S.transaction_cancel() -> None
191 Cancel the currently active transaction.
193 return _tdb
.Tdb_transaction_cancel(*args
, **kwargs
)
195 def hash_size(*args
, **kwargs
):
196 """S.hash_size() -> int"""
197 return _tdb
.Tdb_hash_size(*args
, **kwargs
)
199 def map_size(*args
, **kwargs
):
200 """S.map_size() -> int"""
201 return _tdb
.Tdb_map_size(*args
, **kwargs
)
203 def get_flags(*args
, **kwargs
):
204 """S.get_flags() -> int"""
205 return _tdb
.Tdb_get_flags(*args
, **kwargs
)
207 def set_max_dead(*args
, **kwargs
):
208 """S.set_max_dead(int) -> None"""
209 return _tdb
.Tdb_set_max_dead(*args
, **kwargs
)
211 def name(*args
, **kwargs
):
214 Return filename of this TDB file.
216 return _tdb
.Tdb_name(*args
, **kwargs
)
219 return "Tdb('%s')" % self
.name()
222 def __getitem__(self
, key
):
223 result
= self
.get(key
)
225 raise KeyError, '%s: %s' % (key
, self
.errorstr())
228 def __setitem__(self
, key
, item
):
229 if self
.store(key
, item
) == -1:
230 raise IOError, self
.errorstr()
232 def __delitem__(self
, key
):
233 if not self
.exists(key
):
234 raise KeyError, '%s: %s' % (key
, self
.errorstr())
237 def __contains__(self
, key
):
238 return self
.exists(key
) != 0
240 def has_key(self
, key
):
241 return self
.exists(key
) != 0
243 def fetch_uint32(self
, key
):
248 return struct
.unpack("<L", data
)[0]
250 def fetch_int32(self
, key
):
255 return struct
.unpack("<l", data
)[0]
259 def __init__(self
, tdb
):
268 self
.key
= self
.tdb
.firstkey()
273 self
.key
= self
.tdb
.nextkey(self
.key
)
279 return self
.TdbIterator(self
)
284 return [k
for k
in iter(self
)]
287 return [self
[k
] for k
in iter(self
)]
290 return [(k
, self
[k
]) for k
in iter(self
)]
293 return len(self
.keys())
303 def itervalues(self
):
313 Tdb
.error
= new_instancemethod(_tdb
.Tdb_error
,None,Tdb
)
314 Tdb
.close
= new_instancemethod(_tdb
.Tdb_close
,None,Tdb
)
315 Tdb
.append
= new_instancemethod(_tdb
.Tdb_append
,None,Tdb
)
316 Tdb
.errorstr
= new_instancemethod(_tdb
.Tdb_errorstr
,None,Tdb
)
317 Tdb
.get
= new_instancemethod(_tdb
.Tdb_get
,None,Tdb
)
318 Tdb
.delete
= new_instancemethod(_tdb
.Tdb_delete
,None,Tdb
)
319 Tdb
.store
= new_instancemethod(_tdb
.Tdb_store
,None,Tdb
)
320 Tdb
.exists
= new_instancemethod(_tdb
.Tdb_exists
,None,Tdb
)
321 Tdb
.firstkey
= new_instancemethod(_tdb
.Tdb_firstkey
,None,Tdb
)
322 Tdb
.nextkey
= new_instancemethod(_tdb
.Tdb_nextkey
,None,Tdb
)
323 Tdb
.lock_all
= new_instancemethod(_tdb
.Tdb_lock_all
,None,Tdb
)
324 Tdb
.unlock_all
= new_instancemethod(_tdb
.Tdb_unlock_all
,None,Tdb
)
325 Tdb
.read_lock_all
= new_instancemethod(_tdb
.Tdb_read_lock_all
,None,Tdb
)
326 Tdb
.read_unlock_all
= new_instancemethod(_tdb
.Tdb_read_unlock_all
,None,Tdb
)
327 Tdb
.reopen
= new_instancemethod(_tdb
.Tdb_reopen
,None,Tdb
)
328 Tdb
.transaction_start
= new_instancemethod(_tdb
.Tdb_transaction_start
,None,Tdb
)
329 Tdb
.transaction_commit
= new_instancemethod(_tdb
.Tdb_transaction_commit
,None,Tdb
)
330 Tdb
.transaction_cancel
= new_instancemethod(_tdb
.Tdb_transaction_cancel
,None,Tdb
)
331 Tdb
.transaction_recover
= new_instancemethod(_tdb
.Tdb_transaction_recover
,None,Tdb
)
332 Tdb
.hash_size
= new_instancemethod(_tdb
.Tdb_hash_size
,None,Tdb
)
333 Tdb
.map_size
= new_instancemethod(_tdb
.Tdb_map_size
,None,Tdb
)
334 Tdb
.get_flags
= new_instancemethod(_tdb
.Tdb_get_flags
,None,Tdb
)
335 Tdb
.set_max_dead
= new_instancemethod(_tdb
.Tdb_set_max_dead
,None,Tdb
)
336 Tdb
.name
= new_instancemethod(_tdb
.Tdb_name
,None,Tdb
)
337 Tdb_swigregister
= _tdb
.Tdb_swigregister
338 Tdb_swigregister(Tdb
)