eric6/Plugins/VcsPlugins/vcsPySvn/SvnUtilities.py

changeset 8240
93b8a353c4bf
parent 8143
2c730d5fd177
diff -r 59a9a658618c -r 93b8a353c4bf eric6/Plugins/VcsPlugins/vcsPySvn/SvnUtilities.py
--- a/eric6/Plugins/VcsPlugins/vcsPySvn/SvnUtilities.py	Wed Apr 14 19:38:19 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsPySvn/SvnUtilities.py	Wed Apr 14 19:59:16 2021 +0200
@@ -8,6 +8,7 @@
 """
 
 import os
+import contextlib
 
 from PyQt5.QtCore import QDateTime, Qt
 
@@ -74,15 +75,10 @@
     Module function to create a default config file suitable for eric.
     """
     config = getConfigPath()
-    try:
+    with contextlib.suppress(OSError):
         os.makedirs(os.path.dirname(config))
-    except OSError:
-        pass
-    try:
-        with open(config, "w") as f:
-            f.write(DefaultConfig)
-    except OSError:
-        pass
+    with contextlib.suppress(OSError), open(config, "w") as f:
+        f.write(DefaultConfig)
 
 
 def amendConfig():
@@ -127,8 +123,5 @@
             newConfig.append(line)
     
     if newConfig != configList:
-        try:
-            with open(config, "w") as f:
-                f.write("\n".join(newConfig))
-        except OSError:
-            pass
+        with contextlib.suppress(OSError), open(config, "w") as f:
+            f.write("\n".join(newConfig))

eric ide

mercurial