21 lines
478 B
Python
21 lines
478 B
Python
|
"""Module for work with config-file."""
|
||
|
|
||
|
from pathlib import Path
|
||
|
|
||
|
import yaml
|
||
|
|
||
|
|
||
|
class Configuration:
|
||
|
"""Class for parsing config-file."""
|
||
|
|
||
|
def __init__(self, path: str) -> None:
|
||
|
"""Init class."""
|
||
|
self.path = path
|
||
|
self.config = self.get()
|
||
|
self.token = self.config["telegram_token"]
|
||
|
|
||
|
def get(self) -> dict:
|
||
|
"""Open file and get all value."""
|
||
|
with Path(self.path).open() as file:
|
||
|
return yaml.safe_load(file)
|