Skip to content
This repository has been archived by the owner on Jun 10, 2023. It is now read-only.

Commit

Permalink
fix lang files
Browse files Browse the repository at this point in the history
  • Loading branch information
RealistikDash committed Oct 8, 2020
1 parent 407763a commit a421ed2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
20 changes: 1 addition & 19 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import json
from helpers.generalhelper import dict_keys
from helpers.generalhelper import dict_keys, JsonFile

__name__ = "ConfigModule"
__author__ = "RealistikDash"
Expand All @@ -24,24 +24,6 @@

config_options = list(default_config.keys())

class JsonFile():
def __init__(self, file_name: str):
self.file = None
self.file_name = file_name
if os.path.exists(file_name):
with open(file_name) as f:
self.file = json.load(f)

def get_file(self) -> dict:
"""Returns the loaded JSON file as a dict."""
return self.file

def write_file(self, new_content : dict) -> None:
"""Writes a new dict to the file."""
with open(self.file_name, 'w') as f:
json.dump(new_content, f, indent=4)
self.file = new_content

def load_config(location : str = "config.json"):
config = JsonFile(location)
user_config_temp = config.get_file()
Expand Down
3 changes: 3 additions & 0 deletions exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ class GDPySCommandNotFound(Exception):

class GDPySCommandMissingPrivileges(Exception):
pass

class LangNotFound(Exception):
"""Raised by langhelper if language is not found."""
19 changes: 19 additions & 0 deletions helpers/generalhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import asyncio
import aiohttp
import logging
import json
from typing import Union

def dict_keys(dictioary: dict) -> tuple:
Expand Down Expand Up @@ -97,6 +98,24 @@ def select_obj_id(table : list, where):

return None

class JsonFile():
def __init__(self, file_name: str):
self.file = None
self.file_name = file_name
if os.path.exists(file_name):
with open(file_name) as f:
self.file = json.load(f)

def get_file(self) -> dict:
"""Returns the loaded JSON file as a dict."""
return self.file

def write_file(self, new_content : dict) -> None:
"""Writes a new dict to the file."""
with open(self.file_name, 'w') as f:
json.dump(new_content, f, indent=4)
self.file = new_content

class UpdateQueryBuilder():
"""Makes it simple to work with long update queries."""
def __init__(self, target_db : str):
Expand Down
1 change: 0 additions & 1 deletion helpers/levelhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ async def rate_level(self, rating : Rating) -> None:
if level.stars and not rating.stars:
cp_diff -= 1
if not level.stars and rating.stars:
logging.debug("Cp for star.")
cp_diff += 1
await user_helper.give_cp(level.account_id, cp_diff)

Expand Down
4 changes: 2 additions & 2 deletions languages/packs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"bumping_ip": "Bumping IP count...",
"count_expired": "Count expired for IP. Resetting.",
"reached_limit": "{0} reached limit for {1} with {2}/{3}",
"passed_limit": "{0} passed limit with {1}/{2}
"passed_limit": "{0} passed limit with {1}/{2}"
},
"runtime": {
"shutdown": "Shutting down! Bye!",
"loading_plugin": "Loading plugin {0}...",
"loading_plugin": "Loading plugin {0}..."
}
}

0 comments on commit a421ed2

Please sign in to comment.