From 96cc1e3964d5ab94847a5756f0494f112b3dac15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Fri, 9 Apr 2010 23:33:52 +0200 Subject: Readded a Session.get_bool() method --- portato/session.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'portato/session.py') diff --git a/portato/session.py b/portato/session.py index be13275..ebf49af 100644 --- a/portato/session.py +++ b/portato/session.py @@ -28,9 +28,6 @@ class Session (object): A small class allowing to save certain states of a program. This class works in a quite abstract manner, as it works with handlers, which define what options to use out of the config file and how to apply them to the program. - - Note: This class currently does not work with boolean config options. If you - want to define boolean values, use 0 and 1. This is future proof. """ # the current session format version @@ -159,6 +156,15 @@ class Session (object): return self._cfg.get(section, key) except NoSuchThing: return None + + def get_bool (self, key, section = None): + if section is None: section = self._name + section = section.upper() + + try: + return self._cfg.getboolean(section, key) + except NoSuchThing, ValueError: + return None def remove (self, key, section = None): if section is None: section = self._name -- cgit v1.2.3