From 9416046a876ffe9d92ef8bff015334fc2be0da39 Mon Sep 17 00:00:00 2001 From: Altay Akkus Date: Fri, 15 Jul 2022 10:29:50 +0200 Subject: [PATCH 1/2] Add append function to pickleshare.py --- pickleshare.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 From e4cf584e6ba23d98082e412f2690f4bb664ce6b8 Mon Sep 17 00:00:00 2001 From: Altay Akkus Date: Fri, 15 Jul 2022 10:30:57 +0200 Subject: [PATCH 2/2] Added test for append function --- test_pickleshare.py | 2 ++ 1 file changed, 2 insertions(+) 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)]