eric6/Plugins/VcsPlugins/vcsPySvn/SvnUtilities.py

branch
maintenance
changeset 8273
698ae46f40a4
parent 8240
93b8a353c4bf
equal deleted inserted replaced
8190:fb0ef164f536 8273:698ae46f40a4
6 """ 6 """
7 Module implementing some common utility functions for the pysvn package. 7 Module implementing some common utility functions for the pysvn package.
8 """ 8 """
9 9
10 import os 10 import os
11 import contextlib
11 12
12 from PyQt5.QtCore import QDateTime, Qt 13 from PyQt5.QtCore import QDateTime, Qt
13 14
14 import Utilities 15 import Utilities
15 16
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

eric ide

mercurial