From 88d91af382266b3e42ffcf4c072a1d2eb0c392b9 Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Sat, 3 Jul 2021 18:41:28 +0200 Subject: [PATCH] Moved getConfig to utils. --- torrentSearch/utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/torrentSearch/utils.py b/torrentSearch/utils.py index 225147a..c7562ed 100644 --- a/torrentSearch/utils.py +++ b/torrentSearch/utils.py @@ -6,12 +6,15 @@ # @Last Modified time: 2017-12-22 12:07:18 import re +import os import logging import colored +import configparser from datetime import datetime from colored import stylize +BASE_DIR = os.path.dirname(os.path.abspath(__file__)) SYMBOLS = { 'customary' : ('B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'), 'customary_ext' : ('byte', 'kilo', 'mega', 'giga', 'tera', 'peta', 'exa', @@ -23,6 +26,19 @@ SYMBOLS = { __all__ = ('ColorizeFilter', ) +def getConfig(): + """ + Read path and get configuartion file with site settings + + :return: config settings read from 'config.ini' + :rtype: configparser.ConfigParser + """ + config = configparser.ConfigParser() + config_dir = os.path.join(BASE_DIR, 'config.ini') + config.read(config_dir) + + return config + class ColorizeFilter(logging.Filter): """ Class for setting specific colors to levels of severity for log output