eric6/Plugins/VcsPlugins/vcsSubversion/SvnUtilities.py

changeset 8240
93b8a353c4bf
parent 7923
91e843545d9a
equal deleted inserted replaced
8239:59a9a658618c 8240:93b8a353c4bf
6 """ 6 """
7 Module implementing some common utility functions for the subversion package. 7 Module implementing some common utility functions for the subversion package.
8 """ 8 """
9 9
10 import os 10 import os
11 import contextlib
11 12
12 import Utilities 13 import Utilities
13 14
14 from .Config import DefaultConfig, DefaultIgnores 15 from .Config import DefaultConfig, DefaultIgnores
15 16
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

eric ide

mercurial