Added a to_str function for all classes. __str__ function uses it. highscores_data uses the to_str function for saving.
This commit is contained in:
+10
-1
@@ -31,7 +31,7 @@ class Guild:
|
||||
Returns:
|
||||
str: Guild class as a string
|
||||
"""
|
||||
return json.dumps(self.to_dict(), indent=4)
|
||||
return self.to_str()
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, guild_id: int, data: dict):
|
||||
@@ -226,3 +226,12 @@ class Guild:
|
||||
data["tables"][table.name] = table.to_dict()
|
||||
|
||||
return data
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""
|
||||
Returns Guild object as a string.
|
||||
|
||||
Returns:
|
||||
str: string of json representation of Guild
|
||||
"""
|
||||
return json.dumps(self.to_dict(), indent=4)
|
||||
|
||||
Reference in New Issue
Block a user