mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 00:20:08 +00:00
bitbake/persist_data: Sync file with upstream bitbake
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -66,6 +66,13 @@ class SQLTable(collections.MutableMapping):
|
|||||||
continue
|
continue
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
self.cursor.__enter__()
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, *excinfo):
|
||||||
|
self.cursor.__exit__(*excinfo)
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
data = self._execute("SELECT * from %s where key=?;" %
|
data = self._execute("SELECT * from %s where key=?;" %
|
||||||
self.table, [key])
|
self.table, [key])
|
||||||
@@ -104,35 +111,40 @@ class SQLTable(collections.MutableMapping):
|
|||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
data = self._execute("SELECT key FROM %s;" % self.table)
|
data = self._execute("SELECT key FROM %s;" % self.table)
|
||||||
for row in data:
|
return (row[0] for row in data)
|
||||||
yield row[0]
|
|
||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
if not isinstance(other, Mapping):
|
if not isinstance(other, Mapping):
|
||||||
raise NotImplemented
|
raise NotImplemented
|
||||||
|
|
||||||
def iteritems(self):
|
return len(self) < len(other)
|
||||||
data = self._execute("SELECT * FROM %s;" % self.table)
|
|
||||||
for row in data:
|
def values(self):
|
||||||
yield row[0], row[1]
|
return list(self.itervalues())
|
||||||
|
|
||||||
def itervalues(self):
|
def itervalues(self):
|
||||||
data = self._execute("SELECT value FROM %s;" % self.table)
|
data = self._execute("SELECT value FROM %s;" % self.table)
|
||||||
for row in data:
|
return (row[0] for row in data)
|
||||||
yield row[0]
|
|
||||||
|
|
||||||
def has_key(self, key):
|
def items(self):
|
||||||
return key in self
|
return list(self.iteritems())
|
||||||
|
|
||||||
|
def iteritems(self):
|
||||||
|
return self._execute("SELECT * FROM %s;" % self.table)
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
self._execute("DELETE FROM %s;" % self.table)
|
self._execute("DELETE FROM %s;" % self.table)
|
||||||
|
|
||||||
|
def has_key(self, key):
|
||||||
|
return key in self
|
||||||
|
|
||||||
|
|
||||||
class PersistData(object):
|
class PersistData(object):
|
||||||
"""Deprecated representation of the bitbake persistent data store"""
|
"""Deprecated representation of the bitbake persistent data store"""
|
||||||
def __init__(self, d):
|
def __init__(self, d):
|
||||||
warnings.warn("Use of PersistData will be deprecated in the future",
|
warnings.warn("Use of PersistData is deprecated. Please use "
|
||||||
category=PendingDeprecationWarning,
|
"persist(domain, d) instead.",
|
||||||
|
category=DeprecationWarning,
|
||||||
stacklevel=2)
|
stacklevel=2)
|
||||||
|
|
||||||
self.data = persist(d)
|
self.data = persist(d)
|
||||||
|
|||||||
Reference in New Issue
Block a user