Rev 856 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 856 | Rev 869 | ||
|---|---|---|---|
| 1 | 1 | ||
| 2 | import os |
2 | import os |
| 3 | 3 | ||
| 4 | Settings = {} |
4 | Settings = {} |
| 5 | 5 | ||
| 6 | def FindConfig(): |
6 | def FindConfig(): |
| 7 | filename = "/etc/atom.conf" |
7 | filename = "/etc/atom.conf" |
| 8 | 8 | ||
| 9 | if os.path.exists(filename): |
9 | if os.path.exists(filename): |
| 10 | return filename |
10 | return filename |
| 11 | 11 | ||
| 12 | filename = "./atom.conf" |
12 | filename = "./atom.conf" |
| 13 | 13 | ||
| 14 | if os.path.exists(filename): |
14 | if os.path.exists(filename): |
| 15 | return filename |
15 | return filename |
| 16 | 16 | ||
| 17 | print "No config file found" |
17 | print "No config file found" |
| 18 | return False |
18 | return False |
| 19 | 19 | ||
| 20 | def LoadSettings(): |
20 | def LoadSettings(): |
| 21 | filename = FindConfig() |
21 | filename = FindConfig() |
| 22 | 22 | ||
| 23 | if filename != False: |
23 | if filename != False: |
| 24 | settingsFile = open(filename, 'r') |
24 | settingsFile = open(filename, 'r') |
| 25 | lines = settingsFile.readlines() |
25 | lines = settingsFile.readlines() |
| 26 | settingsFile.close() |
26 | settingsFile.close() |
| 27 | 27 | ||
| 28 | for line in lines: |
28 | for line in lines: |
| 29 | line = line.strip("\n").strip(" ") |
29 | line = line.strip("\n").strip(" ") |
| 30 | if len(line) > 0: |
30 | if len(line) > 0: |
| 31 | if line[0] != '#': |
31 | if line[0] != '#': |
| 32 | settingName = line[:line.find("=")] |
32 | settingName = line[:line.find("=")] |
| 33 | settingValue = line[line.find("=")+1:] |
33 | settingValue = line[line.find("=")+1:] |
| 34 | 34 | ||
| 35 | Settings[settingName] = settingValue |
35 | Settings[settingName] = settingValue |
| 36 | 36 | ||
| 37 | print "Loaded settings from " + filename |
37 | print "Loaded settings from " + filename |
| 38 | 38 | ||
| 39 | print "" |
39 | print "" |
| 40 | 40 | ||