Reformat code with pre-commit

This commit is contained in:
2022-07-21 13:39:41 +01:00
parent 61f6715b20
commit 7c855e09c0
60 changed files with 547 additions and 278 deletions

View File

@@ -1,10 +1,12 @@
import main
# we need a seperate module to log.py, as log.py is imported by main.py, and we need to access main
# to read the setting
def debug(*data):
if main.config["Debug"]:
print("[DEBUG]", *data)
def trace(*data):
if main.config["Trace"]:
print("[TRACE]", *data)

View File

@@ -1,8 +1,10 @@
def log(*data):
print("[LOG]", *data)
def warn(*data):
print("[WARNING]", *data)
def error(*data):
print("[ERROR]", *data)

View File

@@ -1,29 +1,36 @@
import main
def sendData(addr, data):
main.connections[addr].send(data)
def sendWithPrefix(addr, data, prefix):
toSend = ""
for i in data.split("\n"):
toSend += prefix + " " + i + "\n"
sendData(addr, toSend)
def sendSuccess(addr, data):
sendWithPrefix(addr, data, "[y]")
def sendFailure(addr, data):
sendWithPrefix(addr, data, "[n]")
def sendInfo(addr, data):
sendWithPrefix(addr, data, "[i]")
def sendAll(data):
for i in main.connections:
if main.connections[i].authed:
main.connections[i].send(data)
return
def incorrectUsage(addr, mode):
if mode == None:
sendFailure(addr, "Incorrect usage")