[pitivi] settings: Simplify method



commit 462c903ac7234e3ad2678d2c17540d515aa93d08
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Tue Oct 29 16:21:27 2019 +0100

    settings: Simplify method

 pitivi/settings.py    | 20 ++++++++++----------
 pitivi/tabsmanager.py |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/pitivi/settings.py b/pitivi/settings.py
index bba0cfae..a4c0a680 100644
--- a/pitivi/settings.py
+++ b/pitivi/settings.py
@@ -204,8 +204,7 @@ class GlobalSettings(GObject.Object, Loggable):
                 value = self._read_value(section, key, typ)
                 setattr(self, attrname, value)
 
-    @classmethod
-    def readSettingSectionFromFile(self, cls, section):
+    def read_setting_section_from_file(self, section):
         """Reads a particular section of the settings file.
 
         Use this if you dynamically determine settings sections/keys at runtime.
@@ -214,21 +213,21 @@ class GlobalSettings(GObject.Object, Loggable):
         never be read, thus values would be reset to defaults on every startup
         because GlobalSettings would think they don't exist.
         """
-        if cls._config.has_section(section):
-            for option in cls._config.options(section):
+        if self._config.has_section(section):
+            for option in self._config.options(section):
                 # We don't know the value type in advance, just try them all.
                 try:
-                    value = cls._config.getfloat(section, option)
+                    value = self._config.getfloat(section, option)
                 except ValueError:
                     try:
-                        value = cls._config.getint(section, option)
+                        value = self._config.getint(section, option)
                     except ValueError:
                         try:
-                            value = cls._config.getboolean(section, option)
+                            value = self._config.getboolean(section, option)
                         except ValueError:
-                            value = cls._config.get(section, option)
+                            value = self._config.get(section, option)
 
-                setattr(cls, section + option, value)
+                setattr(self, section + option, value)
 
     def _readSettingsFromEnvironmentVariables(self):
         """Reads settings from their registered environment variables."""
@@ -313,7 +312,8 @@ class GlobalSettings(GObject.Object, Loggable):
         beforehand will be loaded.
 
         If you want to add configuration options after initialization,
-        use the `readSettingSectionFromFile` method to force reading later on.
+        use the `read_setting_section_from_file` method to read them from
+        the file.
 
         Args:
             attrname (str): The attribute of this class for accessing the option.
diff --git a/pitivi/tabsmanager.py b/pitivi/tabsmanager.py
index eb8d7054..1ef0366b 100644
--- a/pitivi/tabsmanager.py
+++ b/pitivi/tabsmanager.py
@@ -158,4 +158,4 @@ class BaseTabs(Gtk.Notebook, Loggable):
                                        key="y",
                                        default=0)
 
-        GlobalSettings.readSettingSectionFromFile(self.settings, child_name)
+        self.settings.read_setting_section_from_file(child_name)


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