staticoso/Source/Modules/Config.py

32 lines
708 B
Python
Raw Normal View History

2022-07-11 17:28:59 +02:00
""" ================================= |
| This file is part of |
| staticoso |
| Just a simple Static Site Generator |
| |
| Licensed under the AGPLv3 license |
| Copyright (C) 2022, OctoSpacc |
| ================================= """
import configparser
from ast import literal_eval
def LoadConf(File):
Conf = configparser.ConfigParser()
Conf.read(File)
return Conf
def ReadConf(Conf, Sect, Opt=None):
if Opt:
if Conf.has_option(Sect, Opt):
return Conf[Sect][Opt]
else:
if Conf.has_section(Sect):
return Conf[Sect]
return None
def EvalOpt(Opt):
if Opt:
return literal_eval(Opt)
else:
return None