bitbake: persist_data: add get_by_pattern method to API
authorConstantin Musca <constantinx.musca@intel.com>
Tue, 22 Jan 2013 09:37:57 +0000 (11:37 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 22 Jan 2013 15:35:06 +0000 (15:35 +0000)
- one can use get_by_pattern to get a list of values associated
with keys that match the specified pattern

(Bitbake rev: 6ee1f58698e2d782c54ce5aec271bcec26107eac)

Signed-off-by: Constantin Musca <constantinx.musca@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/bb/persist_data.py

index c69758d..994e61b 100644 (file)
@@ -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())