mirror of
https://gitlab.com/octtspacc/staticoso
synced 2025-06-05 22:09:23 +02:00
Some site settings in INI file
This commit is contained in:
31
Source/Modules/Config.py
Normal file
31
Source/Modules/Config.py
Normal 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
|
Reference in New Issue
Block a user