From 71a2a3fd8b13f6c3e942df5e68bb56e5aad50c2f Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Tue, 14 Jun 2022 17:55:01 -0500 Subject: AƱadido lector de config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/config.py (limited to 'src/config.py') diff --git a/src/config.py b/src/config.py new file mode 100644 index 0000000..4191c4d --- /dev/null +++ b/src/config.py @@ -0,0 +1,27 @@ +import configparser + +class Config: + """ + A cconfig reader class. + """ + def __init__(self, config_file): + self._parser = configparser.ConfigParser() + self._parser.read(config_file) + + def get_server_config(self): + host = self._parser['Server']['host'] + version = self._parser['Server']['api_version'] + + return (host, version) + + def get_auth(self): + auth = self._parser['Auth']['key'] + + return auth + + def get_directories(self): + download = self._parser['Directories']['download_folder'] + delete_after_playing = bool(self._parser['Directories'] + ['delete_after_playing']) + + return (download, delete_after_playing) -- cgit v1.2.3