summaryrefslogtreecommitdiff
path: root/portato
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2009-01-28 16:04:32 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2009-01-28 16:04:32 +0100
commit1f25c87bad1ffcbe7708a3126c9465fba6644fe5 (patch)
tree387fc376121faedf858abff7d57050a0173a7374 /portato
parent2a5e9163052e607e509da61c674502cad30de65c (diff)
downloadportato-1f25c87bad1ffcbe7708a3126c9465fba6644fe5.tar.gz
portato-1f25c87bad1ffcbe7708a3126c9465fba6644fe5.tar.bz2
portato-1f25c87bad1ffcbe7708a3126c9465fba6644fe5.zip
Add a SectionDict class, which maps a section of a session to a dict.
Diffstat (limited to 'portato')
-rw-r--r--portato/session.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/portato/session.py b/portato/session.py
index 0bafee2..76e5540 100644
--- a/portato/session.py
+++ b/portato/session.py
@@ -13,6 +13,7 @@
from __future__ import absolute_import, with_statement
import os, os.path
+from UserDict import DictMixin
from .config_parser import ConfigParser, SectionNotFoundException
from .constants import SESSION_DIR
@@ -208,3 +209,29 @@ class Session (object):
def check_version (self, vers):
pass # do nothing atm
+
+class SectionDict (DictMixin):
+ """A class, which maps a specific section of a session to a dictionary."""
+
+ def __init__ (self, session, section):
+ self._section = section.upper()
+ self._session = session
+
+ def __getitem__ (self, name):
+ item = self._session.get(name, section = self._section)
+
+ if item is None:
+ raise KeyError, "%s not in section %s" % (name, self._section)
+ return item
+
+ def __setitem__ (self, name, value):
+ self._session.set(name, value, section = self._section)
+
+ def __delitem__ (self, name):
+ self._session.remove(name, self._section)
+
+ def keys (self):
+ return self._session._cfg.vars[self._section].keys()
+
+ def __contains__ (self, name):
+ return self._session.get(name, self._section) is not None
='/portato.git/commit/portato/db/database.py?id=1cb4b2447dd451bd23602f91e08a53538514c13f&follow=1'>Fix commit 7449bc5fb8fRené 'Necoro' Neumann1-3/+3 2010-03-05Ignore swap files in gitRené 'Necoro' Neumann1-0/+1 2010-03-05Added some textual descriptionsRené 'Necoro' Neumann2-1/+8 2010-03-05Add description support to the databasesRené 'Necoro' Neumann4-8/+55 2010-03-04Also parse descriptions from eixRené 'Necoro' Neumann1-2/+2 2009-11-08Added Italian translation. Thanks to Ponsi.René 'Necoro' Neumann3-0/+1166 2009-10-28Changelogv0.13.10.13René 'Necoro' Neumann1-0/+4 2009-10-28Corrected config path handling.René 'Necoro' Neumann2-9/+6 2009-10-28Corrected config path handling.René 'Necoro' Neumann2-9/+6 2009-10-24Fix the segfault in GLib due to wrong encodingRené 'Necoro' Neumann1-0/+1 2009-10-24Wrong debug message in new_version pluginRené 'Necoro' Neumann1-1/+1 2009-10-24Update TRANSLATING to use gitRené 'Necoro' Neumann1-2/+15 2009-10-24Also show revision during startup and with -vRené 'Necoro' Neumann1-1/+5 2009-10-24Adding revison info to version output.René 'Necoro' Neumann3-2/+44 2009-10-23Turn new_version plugin from a mess into sth useful.René 'Necoro' Neumann2-10/+10 2009-10-23Honor branches different from masterRené 'Necoro' Neumann1-2/+4 2009-10-23Change the new_version plugin to use git.René 'Necoro' Neumann2-32/+33 2009-10-15Objectified all the functional stuff in backend.__init__.René 'Necoro' Neumann2-32/+34 2009-10-08Enhance the splash window handling.René 'Necoro' Neumann2-2/+9 2009-10-08Enhance the splash window handling.René 'Necoro' Neumann2-2/+9 2009-10-05Some more stuff to ignoreRené 'Necoro' Neumann1-0/+3 2009-10-05Renamed the ignore fileRené 'Necoro' Neumann1-0/+0 2009-10-05Update NEWSRené 'Necoro' Neumann1-0/+1 2009-10-05Also allow 'unselect all' in the PkgListRené 'Necoro' Neumann1-1/+10 2009-10-05Now have it the sorted way in PkgListsRené 'Necoro' Neumann2-3/+9 2009-10-05Enhanced system.sort_package_list to also sort CPVsRené 'Necoro' Neumann5-27/+38 2009-10-05Added an PkgList window and rewrote UpdateWindow and WorldListWindow to use itRené 'Necoro' Neumann3-39/+63 2009-10-05Add uninstall button and rename to PkgListWindowRené 'Necoro' Neumann1-2/+17 2009-10-05First quick hack to have a world listRené 'Necoro' Neumann3-2/+24