]> git.0d.be Git - botaradio.git/blob - constants.py
Fix ffmpeg pipe on Windows
[botaradio.git] / constants.py
1 import variables as var
2
3 def strings(option, *argv, **kwargs):
4     string = ""
5     try:
6         string = var.config.get("strings", option)
7     except KeyError as e:
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 as e:
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 def commands(command):
26     string = ""
27     try:
28         string = var.config.get("commands", command)
29         return string
30     except KeyError as e:
31         raise KeyError("Missed command in configuration file: '{string}'. ".format(string=command) +
32                        "Please restore you configuration file back to default if necessary.")