summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorYaakov M. Nemoy <loupgaroublond@gmail.com>2008-10-05 02:12:32 -0400
committerYaakov M. Nemoy <loupgaroublond@gmail.com>2008-10-05 02:12:32 -0400
commitaecaf493b4e9a6b2da88a8dd7c14ad7c9e039ad3 (patch)
tree9f70e1b82e0335cffee6a40c149e47d9d5f8fc50 /base
parentc5f9da98ce8cacf1d21641e0e6e9f18d738612ed (diff)
downloadfedora-devshell-aecaf493b4e9a6b2da88a8dd7c14ad7c9e039ad3.tar.gz
fedora-devshell-aecaf493b4e9a6b2da88a8dd7c14ad7c9e039ad3.tar.xz
fedora-devshell-aecaf493b4e9a6b2da88a8dd7c14ad7c9e039ad3.zip
Adds a close method to modules that needs to be implemented somehow
This lets you put code on the end of the lifecycle of a Module object.
Diffstat (limited to 'base')
-rw-r--r--base/base.py3
-rw-r--r--base/module.py2
2 files changed, 5 insertions, 0 deletions
diff --git a/base/base.py b/base/base.py
index 836779b..1010af8 100644
--- a/base/base.py
+++ b/base/base.py
@@ -84,6 +84,7 @@ def shell():
# Go up a module in our stack
elif keyword in ('up', 'cd..', 'cd ..'):
+ shell.stack[-1].close()
shell.stack = shell.stack[:-1]
shell.prompt = shell.prompt[:-1]
@@ -96,6 +97,8 @@ def shell():
# Flush our module stack
elif keyword == 'cd':
+ for obj in shell.stack:
+ obj.close()
shell.stack = []
shell.prompt = prompt
diff --git a/base/module.py b/base/module.py
index d527ea0..58a4bc3 100644
--- a/base/module.py
+++ b/base/module.py
@@ -1,4 +1,6 @@
class Module(object):
""" Our parent class for all command modules """
+ def close(self):
+ raise NotImplementedError
pass