From 231b5f67844da39949e04ae53557cea04aacffdd Mon Sep 17 00:00:00 2001
From: Richard Purdie <rpurdie@linux.intel.com>
Date: Wed, 29 Jul 2009 14:10:11 +0100
Subject: bitbake: Add renameDomain and getKeyValues functions to the
 persistent data code

Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
---
 bitbake-dev/lib/bb/persist_data.py | 20 ++++++++++++++++++++
 bitbake/lib/bb/persist_data.py     | 20 ++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/bitbake-dev/lib/bb/persist_data.py b/bitbake-dev/lib/bb/persist_data.py
index 79e7448be..ea921072c 100644
--- a/bitbake-dev/lib/bb/persist_data.py
+++ b/bitbake-dev/lib/bb/persist_data.py
@@ -69,6 +69,26 @@ class PersistData:
         """
         self.connection.execute("DROP TABLE IF EXISTS %s;" % domain)
 
+
+    def renameDomain(self, domain, newdomain):
+        """
+        Renames a domain, removing the target if it already exists
+        """
+ 
+        self.connection.execute("DROP TABLE IF EXISTS %s;" % newdomain)
+        self.connection.execute("ALTER TABLE %s RENAME TO %s;" % (domain, newdomain))
+
+    def getKeyValues(self, domain):
+        """
+        Return a list of key + value pairs for a domain
+        """
+        ret = {}
+        data = self.connection.execute("SELECT key, value from %s;" % domain)
+        for row in data:
+            ret[str(row[0])] = str(row[1])
+
+	return ret
+
     def getValue(self, domain, key):
         """
         Return the value of a key for a domain
diff --git a/bitbake/lib/bb/persist_data.py b/bitbake/lib/bb/persist_data.py
index 79e7448be..ea921072c 100644
--- a/bitbake/lib/bb/persist_data.py
+++ b/bitbake/lib/bb/persist_data.py
@@ -69,6 +69,26 @@ class PersistData:
         """
         self.connection.execute("DROP TABLE IF EXISTS %s;" % domain)
 
+
+    def renameDomain(self, domain, newdomain):
+        """
+        Renames a domain, removing the target if it already exists
+        """
+ 
+        self.connection.execute("DROP TABLE IF EXISTS %s;" % newdomain)
+        self.connection.execute("ALTER TABLE %s RENAME TO %s;" % (domain, newdomain))
+
+    def getKeyValues(self, domain):
+        """
+        Return a list of key + value pairs for a domain
+        """
+        ret = {}
+        data = self.connection.execute("SELECT key, value from %s;" % domain)
+        for row in data:
+            ret[str(row[0])] = str(row[1])
+
+	return ret
+
     def getValue(self, domain, key):
         """
         Return the value of a key for a domain
-- 
cgit v1.2.3