lib/util: hex_encode_talloc(): fix error path and set talloc name
[Samba/vfs_proxy.git] / lib / tdb / tdb.py
blob42129d20911ad804005bd72daadde1607c82c9ef
1 # This file was automatically generated by SWIG (http://www.swig.org).
2 # Version 1.3.36
4 # Don't modify this file, modify the SWIG interface instead.
6 """
7 TDB is a simple key-value database similar to GDBM that supports multiple writers.
8 """
10 import _tdb
11 import new
12 new_instancemethod = new.instancemethod
13 try:
14 _swig_property = property
15 except NameError:
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)
19 if (name == "this"):
20 if type(value).__name__ == 'PySwigObject':
21 self.__dict__[name] = value
22 return
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
27 else:
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
39 def _swig_repr(self):
40 try: strthis = "proxy of " + self.this.__repr__()
41 except: strthis = ""
42 return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
44 import types
45 try:
46 _object = types.ObjectType
47 _newclass = 1
48 except AttributeError:
49 class _object : pass
50 _newclass = 0
51 del types
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"):
58 set(self,name,value)
59 else:
60 raise AttributeError("You cannot add attributes to %s" % self)
61 return set_attr
64 REPLACE = _tdb.REPLACE
65 INSERT = _tdb.INSERT
66 MODIFY = _tdb.MODIFY
67 DEFAULT = _tdb.DEFAULT
68 CLEAR_IF_FIRST = _tdb.CLEAR_IF_FIRST
69 INTERNAL = _tdb.INTERNAL
70 NOLOCK = _tdb.NOLOCK
71 NOMMAP = _tdb.NOMMAP
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
85 class Tdb(object):
86 """A TDB file."""
87 thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
88 __repr__ = _swig_repr
89 def __init__(self, *args, **kwargs):
90 """
91 S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600)
92 Open a TDB file.
93 """
94 _tdb.Tdb_swiginit(self,_tdb.new_Tdb(*args, **kwargs))
95 def error(*args, **kwargs):
96 """
97 S.error() -> int
98 Find last error number returned by operation on this TDB.
99 """
100 return _tdb.Tdb_error(*args, **kwargs)
102 __swig_destroy__ = _tdb.delete_Tdb
103 def close(*args, **kwargs):
105 S.close() -> None
106 Close the TDB file.
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
120 Fetch a value.
122 return _tdb.Tdb_get(*args, **kwargs)
124 def delete(*args, **kwargs):
126 S.delete(key) -> None
127 Delete an entry.
129 return _tdb.Tdb_delete(*args, **kwargs)
131 def store(*args, **kwargs):
133 S.store(key, value, flag=TDB_REPLACE) -> None
134 Store an entry.
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):
147 S.firstkey() -> data
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):
169 S.reopen() -> bool
170 Reopen this file.
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):
213 S.name() -> path
214 Return filename of this TDB file.
216 return _tdb.Tdb_name(*args, **kwargs)
218 def __repr__(self):
219 return "Tdb('%s')" % self.name()
222 def __getitem__(self, key):
223 result = self.get(key)
224 if result is None:
225 raise KeyError, '%s: %s' % (key, self.errorstr())
226 return result
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())
235 self.delete(key)
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):
244 data = self.get(key)
245 if data is None:
246 return None
247 import struct
248 return struct.unpack("<L", data)[0]
250 def fetch_int32(self, key):
251 data = self.get(key)
252 if data is None:
253 return None
254 import struct
255 return struct.unpack("<l", data)[0]
258 class TdbIterator:
259 def __init__(self, tdb):
260 self.tdb = tdb
261 self.key = None
263 def __iter__(self):
264 return self
266 def next(self):
267 if self.key is None:
268 self.key = self.tdb.firstkey()
269 if self.key is None:
270 raise StopIteration
271 return self.key
272 else:
273 self.key = self.tdb.nextkey(self.key)
274 if self.key is None:
275 raise StopIteration
276 return self.key
278 def __iter__(self):
279 return self.TdbIterator(self)
283 def keys(self):
284 return [k for k in iter(self)]
286 def values(self):
287 return [self[k] for k in iter(self)]
289 def items(self):
290 return [(k, self[k]) for k in iter(self)]
292 def __len__(self):
293 return len(self.keys())
295 def clear(self):
296 for k in iter(self):
297 del(self[k])
299 def iterkeys(self):
300 for k in iter(self):
301 yield k
303 def itervalues(self):
304 for k in iter(self):
305 yield self[k]
307 def iteritems(self):
308 for k in iter(self):
309 yield (k, self[k])
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)
340 __docformat__ = 'restructuredText'
341 open = Tdb