[pitivi] settings: Return values of the proper type in readSettingSectionFromFile
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] settings: Return values of the proper type in readSettingSectionFromFile
- Date: Thu, 8 Nov 2012 21:57:59 +0000 (UTC)
commit 03596cc078fc585bfaf1676592a6e1a20f17e1b1
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date: Wed Nov 7 23:27:17 2012 -0500
settings: Return values of the proper type in readSettingSectionFromFile
pitivi/settings.py | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/settings.py b/pitivi/settings.py
index aab0f8b..7737362 100644
--- a/pitivi/settings.py
+++ b/pitivi/settings.py
@@ -199,9 +199,18 @@ class GlobalSettings(Signallable):
"""
if cls._config.has_section(section):
for option in cls._config.options(section):
- value = cls._config.get(section, option)
- if value.isdigit():
- value = int(value)
+ # We don't know the value type in advance, just try them all.
+ try:
+ value = cls._config.getfloat(section, option)
+ except:
+ try:
+ value = cls._config.getint(section, option)
+ except:
+ try:
+ value = cls._config.getboolean(section, option)
+ except:
+ value = cls._config.get(section, option)
+
setattr(cls, section + option, value)
def _readSettingsFromEnvironmentVariables(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]