From 6a0751d5eba64cbfb8b0446a482ed0e014906ca1 Mon Sep 17 00:00:00 2001 From: parksddd Date: Mon, 17 Feb 2020 17:38:38 -0500 Subject: [PATCH 1/3] Fixed Arguments Added argument key words for this example. Without the named arguments it was broken as it looks like the order changed at some point. --- examples/4_totp_storage.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/4_totp_storage.py b/examples/4_totp_storage.py index 4de5715..54bf14a 100644 --- a/examples/4_totp_storage.py +++ b/examples/4_totp_storage.py @@ -87,22 +87,22 @@ def to_json(self, secret): async def add(self, bot, team, issuer, secret): val = json.dumps(self.to_json(secret)) - await bot.kvstore.put(self.NAMESPACE, issuer, val, team) + await bot.kvstore.put(namespace=self.NAMESPACE, entry_key=issuer,entry_value=val,team=team) async def remove(self, bot, team, issuer): # throws exception if nothing to delete - await bot.kvstore.delete(self.NAMESPACE, issuer, team) + await bot.kvstore.delete(namespace=self.NAMESPACE, entry_key=issuer, team=team) async def list(self, bot, team): # returns all TOTP entryKeys (the issuers) in this team - res = await bot.kvstore.list_entrykeys(self.NAMESPACE, team) + res = await bot.kvstore.list_entrykeys(namespace=self.NAMESPACE, team=team) if res.entry_keys: return [e.entry_key for e in res.entry_keys] else: return [] async def now(self, bot, team, issuer): - res = await bot.kvstore.get(self.NAMESPACE, issuer, team) + res = await bot.kvstore.get(namespace=self.NAMESPACE, entry_key=issuer, team=team) if bot.kvstore.is_present(res): # if secret is present secret = json.loads(res.entry_value)["secret"] From 8218e8c80b296c892fe5f0c2a916e7415b4ead58 Mon Sep 17 00:00:00 2001 From: parksddd Date: Mon, 17 Feb 2020 17:46:38 -0500 Subject: [PATCH 2/3] Adding space after comma Space created. --- examples/4_totp_storage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/4_totp_storage.py b/examples/4_totp_storage.py index 54bf14a..d5d6756 100644 --- a/examples/4_totp_storage.py +++ b/examples/4_totp_storage.py @@ -87,7 +87,7 @@ def to_json(self, secret): async def add(self, bot, team, issuer, secret): val = json.dumps(self.to_json(secret)) - await bot.kvstore.put(namespace=self.NAMESPACE, entry_key=issuer,entry_value=val,team=team) + await bot.kvstore.put(namespace=self.NAMESPACE, entry_key=issuer, entry_value=val, team=team) async def remove(self, bot, team, issuer): # throws exception if nothing to delete From d5912e6fb0146d16820934e5eceac21af1eb3eae Mon Sep 17 00:00:00 2001 From: parksddd Date: Mon, 17 Feb 2020 19:03:28 -0500 Subject: [PATCH 3/3] Reformatting with black Reformatted. --- examples/4_totp_storage.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/4_totp_storage.py b/examples/4_totp_storage.py index d5d6756..9da7aa5 100644 --- a/examples/4_totp_storage.py +++ b/examples/4_totp_storage.py @@ -87,7 +87,9 @@ def to_json(self, secret): async def add(self, bot, team, issuer, secret): val = json.dumps(self.to_json(secret)) - await bot.kvstore.put(namespace=self.NAMESPACE, entry_key=issuer, entry_value=val, team=team) + await bot.kvstore.put( + namespace=self.NAMESPACE, entry_key=issuer, entry_value=val, team=team + ) async def remove(self, bot, team, issuer): # throws exception if nothing to delete @@ -102,7 +104,9 @@ async def list(self, bot, team): return [] async def now(self, bot, team, issuer): - res = await bot.kvstore.get(namespace=self.NAMESPACE, entry_key=issuer, team=team) + res = await bot.kvstore.get( + namespace=self.NAMESPACE, entry_key=issuer, team=team + ) if bot.kvstore.is_present(res): # if secret is present secret = json.loads(res.entry_value)["secret"]