summaryrefslogtreecommitdiff
path: root/ttystatus/status.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2010-06-06 14:14:08 +1200
committerLars Wirzenius <liw@liw.fi>2010-06-06 14:14:08 +1200
commitd1e7b83f5b29c05124a4fc630247fdc97e0957f7 (patch)
treeffc982e190482856e5b63e54a055ac659bd08248 /ttystatus/status.py
parent22b38e86eca00f96b1396240639ce85f27c92f76 (diff)
downloadpython-ttystatus-d1e7b83f5b29c05124a4fc630247fdc97e0957f7.tar.gz
Implement TerminalStatus.__getitem__
Diffstat (limited to 'ttystatus/status.py')
-rw-r--r--ttystatus/status.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/ttystatus/status.py b/ttystatus/status.py
index b51c5c5..6eeb55e 100644
--- a/ttystatus/status.py
+++ b/ttystatus/status.py
@@ -16,7 +16,16 @@
class TerminalStatus(object):
- '''Show status and progress information on a terminal.'''
+ '''Show status and progress information on a terminal.
+
+ All output is provided via widgets of various kinds. Many widgets
+ format data that TerminalStatus stores. TerminalStatus provides a
+ dict interface for setting and retrieving data items. Unlike a real
+ dict, getting a value for a key that has not been set does not
+ result in a KeyError exception, but in the empty string being
+ returned.
+
+ '''
def __init__(self):
self.clear()
@@ -28,3 +37,8 @@ class TerminalStatus(object):
def clear(self):
'''Remove all widgets.'''
self._widgets = []
+ self._values = dict()
+
+ def __getitem__(self, key):
+ '''Return value for key, or the empty string.'''
+ return self._values.get(key, '')