Patchwork [bitbake-devel,2/3] persist_data: add get_by_pattern method to API

login
register
mail settings
Submitter Constantin Musca
Date Jan. 22, 2013, 9:37 a.m.
Message ID <1358847477-6786-1-git-send-email-constantinx.musca@intel.com>
Download mbox | patch
Permalink /patch/43157/
State New
Headers show

Comments

Constantin Musca - Jan. 22, 2013, 9:37 a.m.
- one can use get_by_pattern to get a list of values associated
with keys that match the specified pattern

Signed-off-by: Constantin Musca <constantinx.musca@intel.com>
---
 bitbake/lib/bb/persist_data.py | 5 +++++
 1 file changed, 5 insertions(+)

Patch

diff --git a/bitbake/lib/bb/persist_data.py b/bitbake/lib/bb/persist_data.py
index c69758d..994e61b 100644
--- a/bitbake/lib/bb/persist_data.py
+++ b/bitbake/lib/bb/persist_data.py
@@ -125,6 +125,11 @@  class SQLTable(collections.MutableMapping):
 
         return len(self) < len(other)
 
+    def get_by_pattern(self, pattern):
+        data = self._execute("SELECT * FROM %s WHERE key LIKE ?;" %
+                             self.table, [pattern])
+        return [row[1] for row in data]
+
     def values(self):
         return list(self.itervalues())