]> git.0d.be Git - botaradio.git/blob - constants.py
also accept files according to their extension
[botaradio.git] / constants.py
1 import variables as var
2
3
4 def strings(option, *argv, **kwargs):
5     try:
6         string = var.config.get("strings", option)
7     except KeyError:
8         raise KeyError("Missed strings in configuration file: '{string}'. ".format(string=option)
9                        + "Please restore you configuration file back to default if necessary.")
10     if argv or kwargs:
11         try:
12             formatted = string.format(*argv, **kwargs)
13             return formatted
14         except KeyError as e:
15             raise KeyError(
16                 "Missed/Unexpected placeholder {{{placeholder}}} in string '{string}'. ".format(placeholder=str(e).strip("'"), string=option)
17                 + "Please restore you configuration file back to default if necessary.")
18         except TypeError:
19             raise KeyError(
20                 "Missed placeholder in string '{string}'. ".format(string=option)
21                 + "Please restore you configuration file back to default if necessary.")
22     else:
23         return string
24
25
26 def commands(command):
27     try:
28         string = var.config.get("commands", command)
29         return string
30     except KeyError:
31         raise KeyError("Missed command in configuration file: '{string}'. ".format(string=command)
32                        + "Please restore you configuration file back to default if necessary.")