summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/persist_data.py36
1 files changed, 24 insertions, 12 deletions
diff --git a/bitbake/lib/bb/persist_data.py b/bitbake/lib/bb/persist_data.py
index 0ed0cd28e7..551b58a2a9 100644
--- a/bitbake/lib/bb/persist_data.py
+++ b/bitbake/lib/bb/persist_data.py
@@ -66,6 +66,13 @@ class SQLTable(collections.MutableMapping):
66 continue 66 continue
67 raise 67 raise
68 68
69 def __enter__(self):
70 self.cursor.__enter__()
71 return self
72
73 def __exit__(self, *excinfo):
74 self.cursor.__exit__(*excinfo)
75
69 def __getitem__(self, key): 76 def __getitem__(self, key):
70 data = self._execute("SELECT * from %s where key=?;" % 77 data = self._execute("SELECT * from %s where key=?;" %
71 self.table, [key]) 78 self.table, [key])
@@ -104,35 +111,40 @@ class SQLTable(collections.MutableMapping):
104 111
105 def __iter__(self): 112 def __iter__(self):
106 data = self._execute("SELECT key FROM %s;" % self.table) 113 data = self._execute("SELECT key FROM %s;" % self.table)
107 for row in data: 114 return (row[0] for row in data)
108 yield row[0]
109 115
110 def __lt__(self, other): 116 def __lt__(self, other):
111 if not isinstance(other, Mapping): 117 if not isinstance(other, Mapping):
112 raise NotImplemented 118 raise NotImplemented
113 119
114 def iteritems(self): 120 return len(self) < len(other)
115 data = self._execute("SELECT * FROM %s;" % self.table) 121
116 for row in data: 122 def values(self):
117 yield row[0], row[1] 123 return list(self.itervalues())
118 124
119 def itervalues(self): 125 def itervalues(self):
120 data = self._execute("SELECT value FROM %s;" % self.table) 126 data = self._execute("SELECT value FROM %s;" % self.table)
121 for row in data: 127 return (row[0] for row in data)
122 yield row[0]
123 128
124 def has_key(self, key): 129 def items(self):
125 return key in self 130 return list(self.iteritems())
131
132 def iteritems(self):
133 return self._execute("SELECT * FROM %s;" % self.table)
126 134
127 def clear(self): 135 def clear(self):
128 self._execute("DELETE FROM %s;" % self.table) 136 self._execute("DELETE FROM %s;" % self.table)
129 137
138 def has_key(self, key):
139 return key in self
140
130 141
131class PersistData(object): 142class PersistData(object):
132 """Deprecated representation of the bitbake persistent data store""" 143 """Deprecated representation of the bitbake persistent data store"""
133 def __init__(self, d): 144 def __init__(self, d):
134 warnings.warn("Use of PersistData will be deprecated in the future", 145 warnings.warn("Use of PersistData is deprecated. Please use "
135 category=PendingDeprecationWarning, 146 "persist(domain, d) instead.",
147 category=DeprecationWarning,
136 stacklevel=2) 148 stacklevel=2)
137 149
138 self.data = persist(d) 150 self.data = persist(d)