Completed
Push — master ( 328aed...cd5ba9 )
by Jaisen
01:01
created

load_config()   A

↳ Parent: Project

Complexity

Conditions 3

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 10

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
dl 0
loc 10
rs 9.4285
c 1
b 0
f 0
1
"""Load config file as a singleton."""
2
from configparser import RawConfigParser
3
from os import path
4
5
from elodie import constants
6
7
config_file = '%s/config.ini' % constants.application_directory
8
9
10
def load_config():
11
    if hasattr(load_config, "config"):
12
        return load_config.config
13
14
    if not path.exists(config_file):
15
        return {}
16
17
    load_config.config = RawConfigParser()
18
    load_config.config.read(config_file)
19
    return load_config.config
20