mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 18:27:59 -05:00
[V3 Config] Driver code initial cleanup (#1315)
* Remove get_driver * Rename self.driver to self._driver * Do not unnecessarily pass the cog identifier * Remove unused import * Fix type annotation * Missed a keyword rename * Modify signature of get/set methods in drivers
This commit is contained in:
@@ -71,16 +71,15 @@ class Mongo(BaseDriver):
|
||||
uuid, identifiers = identifiers[0], identifiers[1:]
|
||||
return uuid, identifiers
|
||||
|
||||
async def get(self, identifiers: Tuple[str]):
|
||||
async def get(self, *identifiers: Tuple[str]):
|
||||
await self._ensure_connected()
|
||||
uuid, identifiers = self._parse_identifiers(identifiers)
|
||||
|
||||
mongo_collection = self.get_collection()
|
||||
|
||||
dot_identifiers = '.'.join(identifiers)
|
||||
|
||||
partial = await mongo_collection.find_one(
|
||||
filter={'_id': uuid},
|
||||
filter={'_id': self.unique_cog_identifier},
|
||||
projection={dot_identifiers: True}
|
||||
)
|
||||
|
||||
@@ -92,23 +91,19 @@ class Mongo(BaseDriver):
|
||||
partial = partial[i]
|
||||
return partial
|
||||
|
||||
async def set(self, identifiers: Tuple[str], value):
|
||||
async def set(self, *identifiers: str, value=None):
|
||||
await self._ensure_connected()
|
||||
uuid, identifiers = self._parse_identifiers(identifiers)
|
||||
|
||||
dot_identifiers = '.'.join(identifiers)
|
||||
|
||||
mongo_collection = self.get_collection()
|
||||
|
||||
await mongo_collection.update_one(
|
||||
{'_id': uuid},
|
||||
{'_id': self.unique_cog_identifier},
|
||||
update={"$set": {dot_identifiers: value}},
|
||||
upsert=True
|
||||
)
|
||||
|
||||
def get_driver(self):
|
||||
return self
|
||||
|
||||
|
||||
def get_config_details():
|
||||
host = input("Enter host address: ")
|
||||
|
||||
Reference in New Issue
Block a user