[kernel] r11168 - people/waldi/dkt/bin

Bastian Blank waldi at alioth.debian.org
Fri Apr 25 13:17:03 UTC 2008


Author: waldi
Date: Fri Apr 25 13:17:02 2008
New Revision: 11168

Log:
bin/dkt-maintainer: Move some informations into class variables.


Modified:
   people/waldi/dkt/bin/dkt-maintainer

Modified: people/waldi/dkt/bin/dkt-maintainer
==============================================================================
--- people/waldi/dkt/bin/dkt-maintainer	(original)
+++ people/waldi/dkt/bin/dkt-maintainer	Fri Apr 25 13:17:02 2008
@@ -28,27 +28,35 @@
         return Config(c)
 
 class MainAllPreInst(MainAll):
+    commands = ('install', 'upgrade', 'abort-upgrade')
+    commands_systemtask = ('install', 'upgrade')
+    type = 'preinst'
+
     def __init__(self, package, version, command, *args):
         super(MainAllPreInst, self).__init__(package, version)
         self.command, self.args = command, args
 
-        if self.command not in ('install', 'upgrade', 'abort-upgrade'):
-            sys.stderr.write("preinst called with unknown argument '%s'\n" % self.command)
+        if self.command not in self.commands:
+            sys.stderr.write("%s called with unknown argument '%s'\n" % (self.type, self.command))
             sys.exit(1)
 
         self.itemconfig = self.itemconfig_create()
 
     def run_systemtask(self):
-        if self.command in ('install', 'upgrade'):
-            super(MainAllPreInst, self).run_systemtask('preinst')
+        if self.command in self.commands_systemtask:
+            super(MainAllPreInst, self).run_systemtask(self.type)
 
 class MainAllPostInst(MainAll):
+    commands = ('configure', 'abort-upgrade', 'abort-remove', 'abort-deconfigure')
+    commands_systemtask = ('configure',)
+    type = 'postinst'
+
     def __init__(self, package, version, command, *args):
         super(MainAllPostInst, self).__init__(package, version)
         self.command, self.args = command, args
 
-        if self.command not in ('configure', 'abort-upgrade', 'abort-remove', 'abort-deconfigure'):
-            sys.stderr.write("postinst called with unknown argument '%s'\n" % self.command)
+        if self.command not in self.commands:
+            sys.stderr.write("%s called with unknown argument '%s'\n" % (self.type, self.command))
             sys.exit(1)
 
         try:
@@ -58,16 +66,20 @@
             sys.exit(1)
 
     def run_systemtask(self):
-        if self.command in ('configure',):
-            super(MainAllPostInst, self).run_systemtask('postinst')
+        if self.command in self.commands_systemtask:
+            super(MainAllPostInst, self).run_systemtask(self.type)
 
 class MainAllPreRm(MainAll):
+    commands = ('remove', 'upgrade', 'deconfigure', 'failed-upgrade')
+    commands_systemtask = ('remove', 'upgrade')
+    type = 'prerm'
+
     def __init__(self, package, version, command, *args):
         super(MainAllPreRm, self).__init__(package, version)
         self.command, self.args = command, args
 
-        if self.command not in ('remove', 'upgrade', 'deconfigure', 'failed-upgrade'):
-            sys.stderr.write("prerm called with unknown argument '%s'\n" % self.command)
+        if self.command not in self.commands:
+            sys.stderr.write("%s called with unknown argument '%s'\n" % (self.type, self.command))
             sys.exit(1)
 
         try:
@@ -77,23 +89,27 @@
             sys.exit(1)
 
     def run_systemtask(self):
-        if self.command in ('remove', 'upgrade'):
-            super(MainAllPreRm, self).run_systemtask('prerm')
+        if self.command in self.commands_systemtask:
+            super(MainAllPreRm, self).run_systemtask(self.type)
 
 class MainAllPostRm(MainAll):
+    commands = ('purge', 'remove', 'upgrade', 'failed-upgrade', 'abort-install', 'abort-upgrade', 'disappear')
+    commands_systemtask = ('purge', 'remove')
+    type = 'postrm'
+
     def __init__(self, package, version, command, *args):
         super(MainAllPostRm, self).__init__(package, version)
         self.command, self.args = command, args
 
-        if self.command not in ('purge', 'remove', 'upgrade', 'failed-upgrade', 'abort-install', 'abort-upgrade', 'disappear'):
-            sys.stderr.write("postrm called with unknown argument '%s'\n" % self.command)
+        if self.command not in self.commands:
+            sys.stderr.write("%s called with unknown argument '%s'\n" % (self.type, self.command))
             sys.exit(1)
 
         self.itemconfig = self.itemconfig_create()
 
     def run_systemtask(self):
-        if self.command in ('purge', 'remove'):
-            super(MainAllPostRm, self).run_systemtask('postrm')
+        if self.command in self.commands_systemtask:
+            super(MainAllPostRm, self).run_systemtask(self.type)
 
 class MainImagePreInst(MainAllPreInst):
     def __call__(self):



More information about the Kernel-svn-changes mailing list