Skip to content

Commit

Permalink
Remove indenting while dumping databases
Browse files Browse the repository at this point in the history
  • Loading branch information
notsniped committed Nov 5, 2023
1 parent 0d47873 commit 47c9d40
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions framework/isobot/db/levelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def load(self) -> dict:

def save(self, data: dict) -> int:
"""Dumps all cached data to your local machine."""
with open("database/levels.json", 'w+', encoding="utf8") as f: json.dump(data, f, indent=4)
with open("database/levels.json", 'w+', encoding="utf8") as f: json.dump(data, f)
return 0

def generate(self, user_id: int) -> int:
Expand Down Expand Up @@ -79,7 +79,7 @@ def get_xp(self, user_id: int) -> int:
"""Fetches a user's current xp."""
levels = self.load()
return levels[str(user_id)]["xp"]

def get_raw(self):
"""Fetches and returns the raw json data in the levelling database."""
levels = self.load()
Expand Down
8 changes: 4 additions & 4 deletions framework/isobot/db/userdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ class UserData():
"""Used to initialize the UserData system."""
def __init__(self):
print("[framework/db/UserData] UserData library initialized.")

def load(self) -> dict:
"""Fetches and returns the latest data from the levelling database."""
with open("database/user_data.json", 'r', encoding="utf8") as f: db = json.load(f)
return db

def save(self, data: dict) -> int:
"""Dumps all cached data to your local machine."""
with open("database/user_data.json", 'w+', encoding="utf8") as f: json.dump(data, f, indent=4)
with open("database/user_data.json", 'w+', encoding="utf8") as f: json.dump(data, f)
return 0

def generate(self, user_id: int) -> int:
"""Generates a new data key for the specified user.\n
Returns `0` if the request was successful, returns `1` if the data key already exists."""
Expand All @@ -33,7 +33,7 @@ def fetch(self, user_id: int, key: str) -> str:
"""Fetches the vakue of a data key, from a specific user."""
userdat = self.load()
return userdat[str(user_id)][key]

def set(self, user_id: int, key: str, value) -> int:
"""Sets a new value for a data key, for a specific user."""
userdat = self.load()
Expand Down
2 changes: 1 addition & 1 deletion framework/isobot/db/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def load(self) -> dict:

def save(self, data: dict) -> int:
"""Dumps all cached data to your local machine."""
with open("database/weather.json", 'w+', encoding="utf-8") as f: json.dump(data, f, indent=4)
with open("database/weather.json", 'w+', encoding="utf-8") as f: json.dump(data, f)
return 0

def new(self, user_id: User):
Expand Down

0 comments on commit 47c9d40

Please sign in to comment.