Commit 6d4d8418 authored by David Trattnig's avatar David Trattnig
Browse files

Static retrieval of config. #44

parent 4791a65c
......@@ -32,6 +32,7 @@ class AuraConfig:
Holds the Engine Configuration as in the file `engine.ini`.
"""
instance = None
ini_path = ""
logger = None
......@@ -52,6 +53,7 @@ class AuraConfig:
self.ini_path = ini_path
self.load_config()
AuraConfig.instance = self
# Defaults
self.set("config_dir", os.path.dirname(ini_path))
......@@ -60,6 +62,15 @@ class AuraConfig:
@staticmethod
def config():
"""
Retrieves the global instances of the configuration.
"""
return AuraConfig.instance
def set(self, key, value):
"""
Setter for some specific config property.
......@@ -111,6 +122,19 @@ class AuraConfig:
def get_database_uri(self):
"""
Retrieves the database connection string.
"""
db_name = self.get("db_name")
db_user = self.get("db_user")
db_pass = str(self.get("db_pass"))
db_host = self.get("db_host")
db_charset = self.get("db_charset", "utf8")
return "mysql://" + db_user + ":" + db_pass + "@" + db_host + "/" + db_name + "?charset=" + db_charset
def load_config(self):
"""
Set config defaults and load settings from file
......@@ -138,15 +162,3 @@ class AuraConfig:
self.set(key, v)
def get_database_uri(self):
"""
Retrieves the database connection string.
"""
db_name = self.get("db_name")
db_user = self.get("db_user")
db_pass = str(self.get("db_pass"))
db_host = self.get("db_host")
db_charset = self.get("db_charset", "utf8")
return "mysql://" + db_user + ":" + db_pass + "@" + db_host + "/" + db_name + "?charset=" + db_charset
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment