r26248: Check in SWIG output so SWIG is not required when running out of svn.
[ab/samba.git/.git] / source4 / lib / tdb / tdb.py
1 # This file was automatically generated by SWIG (http://www.swig.org).
2 # Version 1.3.33
3 #
4 # Don't modify this file, modify the SWIG interface instead.
5 # This file is compatible with both classic and new-style classes.
6
7 import _tdb
8 import new
9 new_instancemethod = new.instancemethod
10 try:
11     _swig_property = property
12 except NameError:
13     pass # Python < 2.2 doesn't have 'property'.
14 def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
15     if (name == "thisown"): return self.this.own(value)
16     if (name == "this"):
17         if type(value).__name__ == 'PySwigObject':
18             self.__dict__[name] = value
19             return
20     method = class_type.__swig_setmethods__.get(name,None)
21     if method: return method(self,value)
22     if (not static) or hasattr(self,name):
23         self.__dict__[name] = value
24     else:
25         raise AttributeError("You cannot add attributes to %s" % self)
26
27 def _swig_setattr(self,class_type,name,value):
28     return _swig_setattr_nondynamic(self,class_type,name,value,0)
29
30 def _swig_getattr(self,class_type,name):
31     if (name == "thisown"): return self.this.own()
32     method = class_type.__swig_getmethods__.get(name,None)
33     if method: return method(self)
34     raise AttributeError,name
35
36 def _swig_repr(self):
37     try: strthis = "proxy of " + self.this.__repr__()
38     except: strthis = ""
39     return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
40
41 import types
42 try:
43     _object = types.ObjectType
44     _newclass = 1
45 except AttributeError:
46     class _object : pass
47     _newclass = 0
48 del types
49
50
51 REPLACE = _tdb.REPLACE
52 INSERT = _tdb.INSERT
53 MODIFY = _tdb.MODIFY
54 DEFAULT = _tdb.DEFAULT
55 CLEAR_IF_FIRST = _tdb.CLEAR_IF_FIRST
56 INTERNAL = _tdb.INTERNAL
57 NOLOCK = _tdb.NOLOCK
58 NOMMAP = _tdb.NOMMAP
59 CONVERT = _tdb.CONVERT
60 BIGENDIAN = _tdb.BIGENDIAN
61 TDB_SUCCESS = _tdb.TDB_SUCCESS
62 TDB_ERR_CORRUPT = _tdb.TDB_ERR_CORRUPT
63 TDB_ERR_IO = _tdb.TDB_ERR_IO
64 TDB_ERR_LOCK = _tdb.TDB_ERR_LOCK
65 TDB_ERR_OOM = _tdb.TDB_ERR_OOM
66 TDB_ERR_EXISTS = _tdb.TDB_ERR_EXISTS
67 TDB_ERR_NOLOCK = _tdb.TDB_ERR_NOLOCK
68 TDB_ERR_LOCK_TIMEOUT = _tdb.TDB_ERR_LOCK_TIMEOUT
69 TDB_ERR_NOEXIST = _tdb.TDB_ERR_NOEXIST
70 TDB_ERR_EINVAL = _tdb.TDB_ERR_EINVAL
71 TDB_ERR_RDONLY = _tdb.TDB_ERR_RDONLY
72 class tdb(_object):
73     __swig_setmethods__ = {}
74     __setattr__ = lambda self, name, value: _swig_setattr(self, tdb, name, value)
75     __swig_getmethods__ = {}
76     __getattr__ = lambda self, name: _swig_getattr(self, tdb, name)
77     def __init__(self): raise AttributeError, "No constructor defined"
78     __repr__ = _swig_repr
79     def error(*args, **kwargs): return _tdb.tdb_error(*args, **kwargs)
80     __swig_destroy__ = _tdb.delete_tdb
81     __del__ = lambda self : None;
82     def close(*args, **kwargs): return _tdb.tdb_close(*args, **kwargs)
83     def append(*args, **kwargs): return _tdb.tdb_append(*args, **kwargs)
84     def errorstr(*args, **kwargs): return _tdb.tdb_errorstr(*args, **kwargs)
85     def fetch(*args, **kwargs): return _tdb.tdb_fetch(*args, **kwargs)
86     def delete(*args, **kwargs): return _tdb.tdb_delete(*args, **kwargs)
87     def store(*args, **kwargs): return _tdb.tdb_store(*args, **kwargs)
88     def exists(*args, **kwargs): return _tdb.tdb_exists(*args, **kwargs)
89     def firstkey(*args, **kwargs): return _tdb.tdb_firstkey(*args, **kwargs)
90     def nextkey(*args, **kwargs): return _tdb.tdb_nextkey(*args, **kwargs)
91     def lock_all(*args, **kwargs): return _tdb.tdb_lock_all(*args, **kwargs)
92     def unlock_all(*args, **kwargs): return _tdb.tdb_unlock_all(*args, **kwargs)
93     def read_lock_all(*args, **kwargs): return _tdb.tdb_read_lock_all(*args, **kwargs)
94     def read_unlock_all(*args, **kwargs): return _tdb.tdb_read_unlock_all(*args, **kwargs)
95     def reopen(*args, **kwargs): return _tdb.tdb_reopen(*args, **kwargs)
96     def transaction_start(*args, **kwargs): return _tdb.tdb_transaction_start(*args, **kwargs)
97     def transaction_commit(*args, **kwargs): return _tdb.tdb_transaction_commit(*args, **kwargs)
98     def transaction_cancel(*args, **kwargs): return _tdb.tdb_transaction_cancel(*args, **kwargs)
99     def transaction_recover(*args, **kwargs): return _tdb.tdb_transaction_recover(*args, **kwargs)
100     def hash_size(*args, **kwargs): return _tdb.tdb_hash_size(*args, **kwargs)
101     def map_size(*args, **kwargs): return _tdb.tdb_map_size(*args, **kwargs)
102     def get_flags(*args, **kwargs): return _tdb.tdb_get_flags(*args, **kwargs)
103     def set_max_dead(*args, **kwargs): return _tdb.tdb_set_max_dead(*args, **kwargs)
104     def name(*args, **kwargs): return _tdb.tdb_name(*args, **kwargs)
105     def __str__(self):
106         return self.name()
107
108
109     def __getitem__(self, key):
110         result = self.fetch(key)
111         if result is None:
112             raise KeyError, '%s: %s' % (key, self.errorstr())
113         return result
114
115     def __setitem__(self, key, item):
116         if self.store(key, item) == -1:
117             raise IOError, self.errorstr()
118
119     def __delitem__(self, key):
120         if not self.exists(key):
121             raise KeyError, '%s: %s' % (key, self.errorstr())
122         self.delete(key)
123
124     def __contains__(self, key):
125         return self.exists(key) != 0
126
127     def has_key(self, key):
128         return self.exists(key) != 0
129
130
131     class TdbIterator:
132         def __init__(self, tdb):
133             self.tdb = tdb
134             self.key = None
135
136         def __iter__(self):
137             return self
138             
139         def next(self):
140             if self.key is None:
141                 self.key = self.tdb.firstkey()
142                 if self.key is None:
143                     raise StopIteration
144                 return self.key
145             else:
146                 self.key = self.tdb.nextkey(self.key)
147                 if self.key is None:
148                     raise StopIteration
149                 return self.key
150
151     def __iter__(self):
152         return self.TdbIterator(self)
153
154
155
156     def keys(self):
157         return [k for k in iter(self)]
158
159     def values(self):
160         return [self[k] for k in iter(self)]
161
162     def items(self):
163         return [(k, self[k]) for k in iter(self)]
164
165     def __len__(self):
166         return len(self.keys())
167
168     def clear(self):
169         for k in iter(self):
170             del(self[k])
171
172
173
174
175
176 tdb_swigregister = _tdb.tdb_swigregister
177 tdb_swigregister(tdb)
178
179 def Tdb(*args, **kwargs):
180     val = _tdb.new_Tdb(*args, **kwargs)
181     return val
182
183
184