diff options
author | Laurie Clark-Michalek <bluepeppers@archlinux.us> | 2010-11-19 14:17:10 +0000 |
---|---|---|
committer | Laurie Clark-Michalek <bluepeppers@archlinux.us> | 2010-11-19 14:17:10 +0000 |
commit | 4eba993739576ffd8ba78b7aa76382a344267800 (patch) | |
tree | b2bba82449beb4131966982c00932458a8c5640c | |
parent | a629b153f8d889133e2fb5984321b0626e94443e (diff) |
Added get_value and get_key functions to BaseDisplay class.
These allow the key/value to be generated seperatly from the other, as if they are not overridden, they will simply return either the classes key or value attribute. This way they are fully backwards compatible.
See the relevent docstring for more information.
-rw-r--r-- | archey.new | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -243,6 +243,20 @@ class BaseDisplay(): def __repr__(self): return '<{0}: key={1}, value={2}>'.format(self.__class__.__name__, self.key, self.value) + def get_key(self): + """ + Return the value of the class' key attribute. If classes wish to customise key generation, + they should override this method + """ + return self.key + + def get_value(self): + """ + Return the value of the class' value attribute. If classes wish to customise value generation, + they should override this method + """ + return self.value + def key_value_pair(self): """ Returns a tuple of the key and value of the current display. @@ -253,7 +267,7 @@ class BaseDisplay(): >>>disp.key_value_pair() ('Foo', 'Bar') """ - return (self.key, self.value) + return (self.get_key(), self.get_value()) #class Hostname: # def __init__(self): |