35 lines
974 B
Python
35 lines
974 B
Python
import argparse
|
|
import configparser
|
|
import os
|
|
import inspect
|
|
|
|
|
|
def init():
|
|
global config
|
|
|
|
# Decide what config-file to use
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('-e', '--environment', choices=['dev', 'prod', 'test'],
|
|
default='prod',
|
|
help='choose what environment type to run.'
|
|
' Defaults to prod')
|
|
args = parser.parse_args()
|
|
|
|
if args.environment == 'dev':
|
|
print("Using devapi.conf")
|
|
configfile = '/../devapi.conf'
|
|
elif args.environment == 'test':
|
|
print("Using testapi.conf")
|
|
configfile = '/../testapi.conf'
|
|
else:
|
|
print("Using api.conf")
|
|
configfile = '/../api.conf'
|
|
|
|
config = configparser.RawConfigParser()
|
|
config.read(os.path.dirname(
|
|
os.path.abspath(inspect.getfile(
|
|
inspect.currentframe()))) + configfile)
|
|
|
|
def contentpath():
|
|
return(config.get('Database','contentpath'))
|