Some site settings in INI file

This commit is contained in:
2022-07-11 17:28:59 +02:00
parent bf438c75f3
commit d5d4ba3f2a
2 changed files with 84 additions and 12 deletions

31
Source/Modules/Config.py Normal file
View File

@ -0,0 +1,31 @@
""" ================================= |
| 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