diff --git a/pickleshare.py b/pickleshare.py index 086f84f..ae59423 100644 --- a/pickleshare.py +++ b/pickleshare.py @@ -105,7 +105,13 @@ def __getitem__(self,key): self.cache[fil] = (obj,mtime) return obj - + + def append(self, key, value): + currentValue = self[key] + currentValue.append(value) + updatedValue = currentValue + self[key] = updatedValue + def __setitem__(self,key,value): """ db['key'] = 5 """ fil = self.root / key diff --git a/test_pickleshare.py b/test_pickleshare.py index 76ab20c..894104b 100644 --- a/test_pickleshare.py +++ b/test_pickleshare.py @@ -12,6 +12,8 @@ def test_pickleshare(tmpdir): assert db['hello'] == 15 db['aku ankka'] = [1,2,313] assert db['aku ankka'] == [1,2,313] + db.append('aku ankka', 42) + assert db['aku ankka'] == [1,2,313,42] db['paths/nest/ok/keyname'] = [1,(5,46)] assert db['paths/nest/ok/keyname'] == [1,(5,46)]