diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2009-01-27 16:18:15 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2009-01-27 16:18:15 +0100 |
commit | 42a17772c7c83261bf4097b53f2396b8fedd4a5e (patch) | |
tree | 3285e2170632df92fe20d7a749c2b9ff6f5e4b50 /portato | |
parent | 6224da7a5810ef8a9309bc0fd919759e832edcf6 (diff) | |
download | portato-42a17772c7c83261bf4097b53f2396b8fedd4a5e.tar.gz portato-42a17772c7c83261bf4097b53f2396b8fedd4a5e.tar.bz2 portato-42a17772c7c83261bf4097b53f2396b8fedd4a5e.zip |
Use session name as default section name
Diffstat (limited to '')
-rw-r--r-- | portato/session.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/portato/session.py b/portato/session.py index 440d4bf..89684be 100644 --- a/portato/session.py +++ b/portato/session.py @@ -42,6 +42,7 @@ class Session (object): self._cfg = None self._handlers = [] + self._name = name if not (os.path.exists(SESSION_DIR) and os.path.isdir(SESSION_DIR)): os.mkdir(SESSION_DIR) @@ -124,20 +125,26 @@ class Session (object): self._cfg.write() - def set (self, key, value, section): + def set (self, key, value, section = ""): + if not section: section = self._name + try: self._cfg.add(key, value, section, with_blankline = False) except SectionNotFoundException: self._cfg.add_section(section) self._cfg.add(key, value, section, with_blankline = False) - def get (self, key, section): + def get (self, key, section = ""): + if not section: section = self._name + try: return self._cfg.get(key, section) except KeyError: return None - def get_boolean (self, key, section): + def get_boolean (self, key, section = ""): + if not section: section = self._name + try: return self._cfg.get_boolean(key, section) except KeyError: |