[V3 Config] Implement a true clear method (#1344)

* Add clear methods to drivers

* Update config clear methods, add to Value

* Add test
This commit is contained in:
Will
2018-02-26 01:07:28 -05:00
committed by palmtree5
parent c1ac78eea4
commit e13de0950c
5 changed files with 68 additions and 19 deletions

View File

@@ -58,3 +58,14 @@ class JSON(BaseDriver):
partial[full_identifiers[-1]] = value
await self.jsonIO._threadsafe_save_json(self.data)
async def clear(self, *identifiers: str):
partial = self.data
full_identifiers = (self.unique_cog_identifier, *identifiers)
for i in full_identifiers[:-1]:
if i not in partial:
break
partial = partial[i]
else:
del partial[identifiers[-1]]
await self.jsonIO._threadsafe_save_json(self.data)