Convert from "print ..." to "print(...)"
[hooke.git] / hooke / plugin / system.py
index 7f490366bb9a0abe0093de350e8d1cb9254530ce..cff15816e194d4908a38fafe0170caf444d73850 100644 (file)
@@ -1,4 +1,19 @@
-# Copyright
+# Copyright (C) 2010-2012 W. Trevor King <wking@tremily.us>
+#
+# This file is part of Hooke.
+#
+# Hooke is free software: you can redistribute it and/or modify it under the
+# terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Hooke.  If not, see <http://www.gnu.org/licenses/>.
 
 """The `system` module provides :class:`SystemPlugin` and several
 associated :class:`hooke.command.Command`\s for interacting with the
@@ -11,22 +26,21 @@ import subprocess
 import sys
 
 from ..command import Command, Argument
-from ..plugin import Builtin
+from . import Builtin
 
 
 class SystemPlugin (Builtin):
     def __init__(self):
         super(SystemPlugin, self).__init__(name='system')
-
-    def commands(self):
-        return [ListDirectoryCommand(), GetWorkingDirectoryCommand(),
-                ChangeDirectoryCommand(), SystemCommand()]
+        self._commands = [
+            ListDirectoryCommand(self), GetWorkingDirectoryCommand(self),
+            ChangeDirectoryCommand(self), SystemCommand(self)]
 
 
 class ListDirectoryCommand (Command):
     """List the files in a directory.
     """
-    def __init__(self):
+    def __init__(self, plugin):
         super(ListDirectoryCommand, self).__init__(
             name='ls', aliases=['dir'],
             arguments=[
@@ -37,7 +51,7 @@ Path to the directory whose contents get listed.  Defaults to the
 current working directory.
 """.strip()),
 ],
-            help=self.__doc__)
+            help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
        outqueue.put('\n'.join(sorted(os.listdir(params['path']))))
@@ -45,9 +59,9 @@ current working directory.
 class GetWorkingDirectoryCommand (Command):
     """Get the current working directory.
     """
-    def __init__(self):
+    def __init__(self, plugin):
         super(GetWorkingDirectoryCommand, self).__init__(
-            name='cwd', aliases=['pwd'], help=self.__doc__)
+            name='cwd', aliases=['pwd'], help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
        outqueue.put(os.getcwd())
@@ -55,7 +69,7 @@ class GetWorkingDirectoryCommand (Command):
 class ChangeDirectoryCommand (Command):
     """Change the current working directory.
     """
-    def __init__(self):
+    def __init__(self, plugin):
         super(ChangeDirectoryCommand, self).__init__(
             name='cd',
             arguments=[
@@ -66,7 +80,7 @@ Path of the directory to change into.  Default to the user's home
 directory.
 """.strip()),
 ],
-            help=self.__doc__)
+            help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
         os.chdir(os.path.expanduser(params['path']))
@@ -74,7 +88,7 @@ directory.
 class SystemCommand (Command):
     """Execute a system command and report the output.
     """
-    def __init__(self):
+    def __init__(self, plugin):
         super(SystemCommand, self).__init__(
             name='system',
             arguments=[
@@ -84,7 +98,7 @@ class SystemCommand (Command):
 Command line to execute.
 """.strip()),
 ],
-            help=self.__doc__)
+            help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
         p = subprocess.Popen(