summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurie Clark-Michalek <bluepeppers@archlinux.us>2010-11-18 18:15:11 +0000
committerLaurie Clark-Michalek <bluepeppers@archlinux.us>2010-11-18 18:15:11 +0000
commit9df585e1a3c97facc97690039c5041d8c548ec6e (patch)
tree3fddbfd6b94abb27787b14c66b5ad19bf52a154f
parent1ba9dc18dcd50e3cbacd42aad53c9ed8a386b122 (diff)
Added BaseDisplay base class.
This class should be inherited by all Display classes. It implements generic display functions, though only repr currently. See help(BaseDisplay) for more info.
-rw-r--r--archey.new37
1 files changed, 27 insertions, 10 deletions
diff --git a/archey.new b/archey.new
index a67c961..7e8b9ab 100644
--- a/archey.new
+++ b/archey.new
@@ -131,11 +131,28 @@ class Output():
def output(self):
print(logosDict[self.distro].format(color = colorDict[self.distro], results = self.results))
-
-class User():
+
+class BaseDisplay():
+ """
+ All display classes should inherit this. It defigns several base functions that can be overwritten by any child classes
+
+ >>>import random
+ >>>class RandomNumber(BaseDisplay):
+ ... key = 'Random Number'
+ ... value = random.random() * 1000
+ ...
+ >>>r = RandomNumber()
+ >>>print `r`
+ """
+
+ key = None
+ value = None
+
def __init__(self):
- self.key = 'User'
- self.value = os.getenv('USER')
+ raise NotImplemented('Display classes must implements their own __init__ function')
+
+ def __repr__(self):
+ return '<{0}: key={1}, value={2}>'.format(self.__class__.__name__, self.key, self.value)
#class Hostname:
# def __init__(self):
@@ -146,7 +163,7 @@ class User():
#class Kernel:
# def __init__(self):
-class Uptime():
+class Uptime(BaseDisplay):
def __init__(self):
fuptime = int(open('/proc/uptime').read().split('.')[0])
day = int(fuptime / 86400)
@@ -163,7 +180,7 @@ class Uptime():
self.key = 'Uptime'
self.value = uptime
-class WindowManager():
+class WindowManager(BaseDisplay):
def __init__(self):
wm = ''
for key in wmDict.keys():
@@ -174,7 +191,7 @@ class WindowManager():
self.key = 'Window Manager'
self.value = wm
-class DesktopEnvironment():
+class DesktopEnvironment(BaseDisplay):
def __init__(self):
de = ''
for key in deDict.keys():
@@ -213,17 +230,17 @@ def enviroment_variable(klass):
return klass
@enviroment_variable
-class Shell():
+class Shell(BaseDisplay):
key = 'Shell'
env = 'SHELL'
@enviroment_variable
-class Terminal():
+class Terminal(BaseDisplay):
key = 'Terminal'
env = 'TERM'
@enviroment_variable
-class User():
+class User(BaseDisplay):
key = 'User'
env = 'USER'