From ff01686c1b38d26b0ef54833cf3463ab0bf73bf8 Mon Sep 17 00:00:00 2001 From: Patrick Maia and Victor Shyba Date: Sun, 7 Sep 2014 16:55:57 +0000 Subject: #51 - some tests for TagIndex and the addition of method TagIndex.add --- service/pixelated/adapter/tag_index.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'service/pixelated') diff --git a/service/pixelated/adapter/tag_index.py b/service/pixelated/adapter/tag_index.py index 25108643..ea69be1a 100644 --- a/service/pixelated/adapter/tag_index.py +++ b/service/pixelated/adapter/tag_index.py @@ -34,6 +34,10 @@ class TagIndex: self.close_db() # force flush self.db = dbm.open(self.db_path, 'c') + def add(self, tag): + if tag.name not in self.db: + self.set(tag) + def get(self, tag_name): if tag_name in self.db: return Tag.from_json_string(self.db.get(tag_name)) -- cgit v1.2.3