45 def createDefaultConfig(): |
46 def createDefaultConfig(): |
46 """ |
47 """ |
47 Module function to create a default config file suitable for eric. |
48 Module function to create a default config file suitable for eric. |
48 """ |
49 """ |
49 config = getConfigPath() |
50 config = getConfigPath() |
50 try: |
51 with contextlib.suppress(OSError): |
51 os.makedirs(os.path.dirname(config)) |
52 os.makedirs(os.path.dirname(config)) |
52 except OSError: |
53 with contextlib.suppress(OSError), open(config, "w") as f: |
53 pass |
54 f.write(DefaultConfig) |
54 try: |
|
55 with open(config, "w") as f: |
|
56 f.write(DefaultConfig) |
|
57 except OSError: |
|
58 pass |
|
59 |
55 |
60 |
56 |
61 def amendConfig(): |
57 def amendConfig(): |
62 """ |
58 """ |
63 Module function to amend the config file. |
59 Module function to amend the config file. |
98 amendList.append(amend) |
94 amendList.append(amend) |
99 else: |
95 else: |
100 newConfig.append(line) |
96 newConfig.append(line) |
101 |
97 |
102 if newConfig != configList: |
98 if newConfig != configList: |
103 try: |
99 with contextlib.suppress(OSError), open(config, "w") as f: |
104 with open(config, "w") as f: |
100 f.write("\n".join(newConfig)) |
105 f.write("\n".join(newConfig)) |
|
106 except OSError: |
|
107 pass |
|