From 9019a849908241e0a50d7af8a524313570aebc60 Mon Sep 17 00:00:00 2001 From: "Piotr (Husio) Husiatynski" Date: Thu, 31 Jan 2008 17:33:49 +0100 Subject: [PATCH] Cleaning the code. --- aur-shell.py | 8 ------- conf.py | 71 ++++++++++++++++++++++++++++++------------------------------ plugload.py | 14 +++++++++--- pyshell | 4 ++++ 4 files changed, 50 insertions(+), 47 deletions(-) rewrite conf.py (72%) diff --git a/aur-shell.py b/aur-shell.py index 67772d7..d6797cf 100644 --- a/aur-shell.py +++ b/aur-shell.py @@ -103,14 +103,6 @@ class AurShell(cmd.Cmd): else: return [] - def postcmd(self, stop, line): - #if line: - # self.history.append(line) - return stop - - def emptyline(self, *ignore): - pass - def do_help(self, arg): """Show help for commands""" if not arg: diff --git a/conf.py b/conf.py dissimilarity index 72% index af8f7b9..bf5cb78 100644 --- a/conf.py +++ b/conf.py @@ -1,36 +1,35 @@ -#!/usr/bin/python -# -*- coding: utf-8-*- - -"""Configuration file""" - -import os -import os.path - - -modules_path = os.path.join(os.getcwd(), "plugin/") -history_file = os.path.join(os.path.expanduser("~"), ".aurshell_history") -history_length = 500 - -shell_prompt = '\033[1;34m [\033[0m\033[1m aurshell \033[34m]\033[0m ' - - -color = { - "none" : "\[\033[0m\]", - "red" : "\[\033[31m\]", - "black" : "\[\033[30m\]", - "green" : "\[\033[32m\]", - "brown" : "\[\033[33m\]", - "blue" : "\[\033[34m\]", - "magenta" : "\[\033[35m\]", - "cyan" : "\[\033[36m\]", - "gray" : "\[\033[37m\]", - "darkgray" : "\[\033[30m\]", - "lightred" : "\[\033[31m\]", - # TODO - #\033[01;32m - light green - #\033[01;33m - yellow - #\033[01;34m - light blue - #\033[01;35m - light magenta - #\033[01;36m - light cyan - #\033[01;37m - white - } +#!/usr/bin/python +# -*- coding: utf-8-*- + +"""Configuration file""" + +import os +import os.path + + +modules_path = os.path.join(os.getcwd(), "plugin/") +history_file = os.path.join(os.path.expanduser("~"), ".aurshell_history") +history_length = 500 + +shell_prompt = " \033[1;34m[\033[0m\033[1m aurshell \033[34m]\033[0m " + + +color = { + "none" : "\[\033[0m\]", + "red" : "\[\033[31m\]", + "black" : "\[\033[30m\]", + "green" : "\[\033[32m\]", + "brown" : "\[\033[33m\]", + "blue" : "\[\033[34m\]", + "magenta" : "\[\033[35m\]", + "cyan" : "\[\033[36m\]", + "gray" : "\[\033[37m\]", + "darkgray" : "\[\033[30m\]", + "lightred" : "\[\033[31m\]", + "lightgreen" : "\[\033[32m\]", + "yellow" : "\[\033[33m\]", + "lightblue" : "\[\033[34m\]", + "lightmagenta" : "\[\033[35m\]", + "lightcyan" : "\[\033[36m\]", + "white" : "\[\033[37m\]", + } diff --git a/plugload.py b/plugload.py index 7adacdd..d1aac80 100644 --- a/plugload.py +++ b/plugload.py @@ -9,7 +9,14 @@ import types import string def load(modules_path): - """Load all commands modules from modules_path direcotory""" + """Load all commands modules from modules_path direcotory. + + Returns a dictionary : + { + "class_name" : class_instance, + ... + } + """ command_modules = [] # adding plugins path to sys.path if modules_path not in sys.path: @@ -20,7 +27,7 @@ def load(modules_path): string.join(modules_path, module_name)) (module_name, module_extension) = os.path.splitext(module_name) # if it shouldn't be load - if os.path.islink(module_path) or \ + if os.path.islink(module_path) or \ module_path == __file__ or \ module_extension != ".py": continue @@ -33,7 +40,8 @@ def load(modules_path): module_objs = {} for module in command_modules: for obj in dir(module["name"]): - # TODO better class serch 2008-01-27 16:56:42 + # TODO + # better class serch 2008-01-27 16:56:42 if not obj.startswith("_") and \ type(getattr(module['name'], obj)) == types.TypeType: # create instance for each class diff --git a/pyshell b/pyshell index b1aaa38..f34fae0 100755 --- a/pyshell +++ b/pyshell @@ -1,3 +1,7 @@ #!/bin/bash + + +# cd SCRIPT_PATH + python aur-shell.py -- 2.11.4.GIT