summaryrefslogtreecommitdiff
path: root/portato/session.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2008-06-10 01:17:56 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2008-06-10 01:17:56 +0200
commit772b3bb14fc3103d774e4e0d907a6c4670ed03f3 (patch)
tree6945a5f7d03838d9c934875377dfcf3d98ebb102 /portato/session.py
parent7a12f4c4031c85e4301d09ea5aa86e55103bb5e1 (diff)
downloadportato-772b3bb14fc3103d774e4e0d907a6c4670ed03f3.tar.gz
portato-772b3bb14fc3103d774e4e0d907a6c4670ed03f3.tar.bz2
portato-772b3bb14fc3103d774e4e0d907a6c4670ed03f3.zip
Allowed default for session; load 'app-portage/portato' as default for selections :)
Diffstat (limited to 'portato/session.py')
-rw-r--r--portato/session.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/portato/session.py b/portato/session.py
index 6abd899..e03f663 100644
--- a/portato/session.py
+++ b/portato/session.py
@@ -54,20 +54,20 @@ class Session (object):
# add version check
self.add_handler(([("version", "session")], self.check_version, lambda: self.VERSION))
- def add_handler (self, (options, load_fn, save_fn)):
+ def add_handler (self, (options, load_fn, save_fn), default = None):
"""
Adds a handler to this session. A handler is a three-tuple consisting of:
- a list of (key,section) values
- a function getting number of option arguments and applying them to the program
- a function returning the number of option return values - getting them out of the program
"""
- self._handlers.append((options, load_fn, save_fn))
+ self._handlers.append((options, load_fn, save_fn, default))
def load (self):
"""
Loads and applies all values of the session.
"""
- for options, lfn, sfn in self._handlers:
+ for options, lfn, sfn, default in self._handlers:
try:
loaded = [self._cfg.get(*x) for x in options]
except KeyError: # does not exist -> ignore
@@ -75,13 +75,18 @@ class Session (object):
else:
debug("Loading %s with values %s.", options, loaded)
lfn(*loaded)
+ return
+
+ if default:
+ debug("Loading %s with defaults %s.", options, default)
+ lfn(*default)
def save (self):
"""
Saves all options into the file.
"""
- for options, lfn, sfn in self._handlers:
+ for options, lfn, sfn, default in self._handlers:
vals = sfn()
# map into list if necessairy
008-01-14 17:04:38 +0100Necoro9-394/+477 Allowed '-' and '_' in key names. Also use group names instead of their number. r610@Devoty: necoro | 2008-01-14 17:05:42 +0100 Disabled saving of the queues r611@Devoty: necoro | 2008-01-14 17:08:53 +0100 Added the possibility to permanently en-/disable plugins r612@Devoty: necoro | 2008-01-14 17:14:09 +0100 adjust changelog and translations r613@Devoty: necoro | 2008-01-14 17:40:53 +0100 Dropdown should be localized too 2008-01-14 r605@Devoty: necoro | 2008-01-14 11:43:34 +0100Necoro2-26/+129 Updated shm module to version 1.1.4 2008-01-14 r603@Devoty: necoro | 2008-01-14 11:30:26 +0100Necoro4-26/+38 Improved 'update world'; really support new use defaults 2008-01-11 r598@Devoty: necoro | 2008-01-10 16:36:29 +0100Necoro4-10/+50 Handle the new useflag format correctly 2008-01-11 r597@Devoty: necoro | 2008-01-10 14:12:35 +0100Necoro1-3/+3 updated todo 2008-01-10 r595@Devoty: necoro | 2008-01-10 04:04:15 +0100Necoro1-52/+3 Re-Introduced etc-proposals 2008-01-09 r586@Devoty: necoro | 2008-01-09 14:54:18 +0100Necoro1-1/+1 Disabled catapult till it is really usable 2007-12-06 r577@Devoty: necoro | 2007-12-06 20:37:36 +0100Necoro1-1/+1 Fixed desktop file 2007-12-06 r572@Devoty: necoro | 2007-11-28 08:48:15 +0100Necoro1-0/+1 2007-11-27 r570@Devoty: necoro | 2007-11-27 02:08:21 +0100Necoro3-84/+108 Added scrollbars to update window