forked from 20xd6/simple_blog_cms
28 lines
901 B
Python
28 lines
901 B
Python
import configparser
|
|
import os
|
|
|
|
import sb_config
|
|
|
|
|
|
def find_ini(): # Test for the existence of a configuration
|
|
conf_found = False
|
|
while not conf_found:
|
|
try:
|
|
option_file = open(os.path.dirname(os.path.realpath(__file__)) + "/.simple-blog.ini", "r")
|
|
base_options = option_file.readlines()
|
|
if len(base_options) > 0:
|
|
option_file_path = os.path.dirname(os.path.realpath(__file__)) + "/.simple-blog.ini"
|
|
return option_file_path
|
|
else:
|
|
sb_config.write_conf("No configuration found in file.", True)
|
|
option_file.close()
|
|
except IOError:
|
|
sb_config.write_conf("No configuration file found.", False)
|
|
|
|
|
|
def return_options():
|
|
option_file = find_ini()
|
|
simple_blog_conf = configparser.ConfigParser()
|
|
simple_blog_conf.read(option_file)
|
|
return simple_blog_conf
|