forked from azlux/botamusique
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstants.py
32 lines (28 loc) · 1.3 KB
/
constants.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import variables as var
def strings(option, *argv, **kwargs):
try:
string = var.config.get("strings", option)
except KeyError:
raise KeyError("Missed strings in configuration file: '{string}'. ".format(string=option)
+ "Please restore you configuration file back to default if necessary.")
if argv or kwargs:
try:
formatted = string.format(*argv, **kwargs)
return formatted
except KeyError as e:
raise KeyError(
"Missed/Unexpected placeholder {{{placeholder}}} in string '{string}'. ".format(placeholder=str(e).strip("'"), string=option)
+ "Please restore you configuration file back to default if necessary.")
except TypeError:
raise KeyError(
"Missed placeholder in string '{string}'. ".format(string=option)
+ "Please restore you configuration file back to default if necessary.")
else:
return string
def commands(command):
try:
string = var.config.get("commands", command)
return string
except KeyError:
raise KeyError("Missed command in configuration file: '{string}'. ".format(string=command)
+ "Please restore you configuration file back to default if necessary.")