Skip to contentSkip to conversation

persist_data: add get_by_pattern method to API

PATCH In review Constantin Musca 1 participant 1 message Jan 22, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 persist_data: add get_by_pattern method to API

- one can use get_by_pattern to get a list of values associated with keys that match the specified pattern

---
 bitbake/lib/bb/persist_data.py | 5 +++++
 1 file changed, 5 insertions(+)
bitbake/lib/bb/persist_data.py +5 -0
index c69758d..994e61b 100644
@@ -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())
 
Signature · 1 line
1.7.11.7