[gnome-tweak-tool] gtksettings: Switch to os.makedirs exist_ok=True



commit 4f0f6c679d7476c26e4d37bb0e477753b624fefa
Author: Jeremy Bicha <jbicha ubuntu com>
Date:   Tue Jun 6 18:04:40 2017 -0400

    gtksettings: Switch to os.makedirs exist_ok=True
    
    Requires Python 3.2

 gtweak/gtksettings.py |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)
---
diff --git a/gtweak/gtksettings.py b/gtweak/gtksettings.py
index d656b2e..a11363b 100644
--- a/gtweak/gtksettings.py
+++ b/gtweak/gtksettings.py
@@ -31,6 +31,8 @@ class GtkSettingsManager:
         self._path = os.path.join(GLib.get_user_config_dir(),
                                   "gtk-" + version,
                                   "settings.ini")
+        os.makedirs(os.path.dirname(self._path), exist_ok=True)
+
     def _get_keyfile(self):
         keyfile = None
         try:
@@ -55,13 +57,6 @@ class GtkSettingsManager:
         keyfile.set_integer(SETTINGS_GROUP_NAME, key, value)
 
         try:
-            os.makedirs(os.path.dirname(self._path))
-        except FileExistsError:
-            pass
-        except:
-            raise
-
-        try:
             data = keyfile.to_data()
             GLib.file_set_contents(self._path, data[0].encode())
         except:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]