Reformat code with pre-commit
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
def log(*data):
|
||||
print("[LOG]", *data)
|
||||
|
||||
|
||||
def warn(*data):
|
||||
print("[WARNING]", *data)
|
||||
|
||||
|
||||
def error(*data):
|
||||
print("[ERROR]", *data)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user