Spaces:
No application file
No application file
Download config_parser.py from babinc027/My-Movie-Bot: direct link, hf CLI and curl.
- Browser
- Download file 520 Bytes
-
https://huggingface.co/spaces/babinc027/My-Movie-Bot/resolve/main/config_parser.py
- Command line
-
hf download hf://spaces/babinc027/My-Movie-Bot/config_parser.py
-
curl -L -o config_parser.py https://huggingface.co/spaces/babinc027/My-Movie-Bot/resolve/main/config_parser.py
520 Bytes
| from os import environ | |
| from typing import Dict, Optional | |
| class TokenParser: | |
| def __init__(self, config_file: Optional[str] = None): | |
| self.tokens = {} | |
| self.config_file = config_file | |
| def parse_from_env(self) -> Dict[int, str]: | |
| self.tokens = dict( | |
| (c + 1, t) | |
| for c, (_, t) in enumerate( | |
| filter( | |
| lambda n: n[0].startswith("MULTI_TOKEN"), sorted(environ.items()) | |
| ) | |
| ) | |
| ) | |
| return self.tokens | |