50 try: |
50 try: |
51 os.makedirs(os.path.dirname(config)) |
51 os.makedirs(os.path.dirname(config)) |
52 except OSError: |
52 except OSError: |
53 pass |
53 pass |
54 try: |
54 try: |
55 f = open(config, "w") |
55 with open(config, "w") as f: |
56 f.write(DefaultConfig) |
56 f.write(DefaultConfig) |
57 f.close() |
|
58 except IOError: |
57 except IOError: |
59 pass |
58 pass |
60 |
59 |
61 |
60 |
62 def amendConfig(): |
61 def amendConfig(): |
63 """ |
62 """ |
64 Module function to amend the config file. |
63 Module function to amend the config file. |
65 """ |
64 """ |
66 config = getConfigPath() |
65 config = getConfigPath() |
67 try: |
66 try: |
68 f = open(config, "r") |
67 with open(config, "r") as f: |
69 configList = f.read().splitlines() |
68 configList = f.read().splitlines() |
70 f.close() |
|
71 except IOError: |
69 except IOError: |
72 return |
70 return |
73 |
71 |
74 newConfig = [] |
72 newConfig = [] |
75 ignoresFound = False |
73 ignoresFound = False |