72 def createDefaultConfig(): |
73 def createDefaultConfig(): |
73 """ |
74 """ |
74 Module function to create a default config file suitable for eric. |
75 Module function to create a default config file suitable for eric. |
75 """ |
76 """ |
76 config = getConfigPath() |
77 config = getConfigPath() |
77 try: |
78 with contextlib.suppress(OSError): |
78 os.makedirs(os.path.dirname(config)) |
79 os.makedirs(os.path.dirname(config)) |
79 except OSError: |
80 with contextlib.suppress(OSError), open(config, "w") as f: |
80 pass |
81 f.write(DefaultConfig) |
81 try: |
|
82 with open(config, "w") as f: |
|
83 f.write(DefaultConfig) |
|
84 except OSError: |
|
85 pass |
|
86 |
82 |
87 |
83 |
88 def amendConfig(): |
84 def amendConfig(): |
89 """ |
85 """ |
90 Module function to amend the config file. |
86 Module function to amend the config file. |
125 amendList.append(amend) |
121 amendList.append(amend) |
126 else: |
122 else: |
127 newConfig.append(line) |
123 newConfig.append(line) |
128 |
124 |
129 if newConfig != configList: |
125 if newConfig != configList: |
130 try: |
126 with contextlib.suppress(OSError), open(config, "w") as f: |
131 with open(config, "w") as f: |
127 f.write("\n".join(newConfig)) |
132 f.write("\n".join(newConfig)) |
|
133 except OSError: |
|
134 pass |
|