76 try: |
76 try: |
77 os.makedirs(os.path.dirname(config)) |
77 os.makedirs(os.path.dirname(config)) |
78 except OSError: |
78 except OSError: |
79 pass |
79 pass |
80 try: |
80 try: |
81 f = open(config, "w") |
81 with open(config, "w") as f: |
82 f.write(DefaultConfig) |
82 f.write(DefaultConfig) |
83 f.close() |
|
84 except IOError: |
83 except IOError: |
85 pass |
84 pass |
86 |
85 |
87 |
86 |
88 def amendConfig(): |
87 def amendConfig(): |
89 """ |
88 """ |
90 Module function to amend the config file. |
89 Module function to amend the config file. |
91 """ |
90 """ |
92 config = getConfigPath() |
91 config = getConfigPath() |
93 try: |
92 try: |
94 f = open(config, "r") |
93 with open(config, "r") as f: |
95 configList = f.read().splitlines() |
94 configList = f.read().splitlines() |
96 f.close() |
|
97 except IOError: |
95 except IOError: |
98 return |
96 return |
99 |
97 |
100 newConfig = [] |
98 newConfig = [] |
101 ignoresFound = False |
99 ignoresFound = False |