summaryrefslogtreecommitdiffstats
path: root/readConfigFile.py
blob: 12bd3641e7817e9e3fbdb99234002b6a4a83f139 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python
import string
import os

def getConfigFile():
    import string

    if os.access("custom/anaconda.conf", os.O_RDONLY):
        f = open("custom/anaconda.conf", "r")
    elif os.access("/usr/share/anaconda/custom/anaconda.conf", os.O_RDONLY):
        f = open("/usr/share/anaconda/custom/anaconda.conf", "r")
    elif os.access("anaconda.conf", os.O_RDONLY):
        f = open("anaconda.conf", "r")
    else:
        f = open("/usr/share/anaconda/anaconda.conf", "r")

    lines = f.readlines()
    f.close()

    dict = {}

    for line in lines:
        line = string.strip(line)

        if string.find (line, "#") > -1 or line == "": 
            pass
        else:
            tokens = string.split(line)
            str = string.join(tokens[1:])
            dict[tokens[0]] = str
    return dict