From: <cl...@us...> - 2003-04-26 22:08:17
|
Update of /cvsroot/todo-manager/todo-manager In directory sc8-pr-cvs1:/tmp/cvs-serv28631 Modified Files: TODO.txt main.py plugin.py Log Message: TODO.txt: Removed 'Select which plugins to load' because it just became impractical main.py: Consolodation of plugin funtions and interface notification plugin.py: No more crashing when loading a plugin that is written poorly or has a syntax error. Added i18n support so debug prints can be multilingual po/core/POTFILES.in: Added plugin.py Index: TODO.txt =================================================================== RCS file: /cvsroot/todo-manager/todo-manager/TODO.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- TODO.txt 8 Mar 2003 07:28:57 -0000 1.16 +++ TODO.txt 26 Apr 2003 22:08:13 -0000 1.17 @@ -3,7 +3,6 @@ Version 1.0: ------------ Core: - * Select which plugins to load * Recurring tasks (daily, weekly, monthly, yearly) Interface: Index: main.py =================================================================== RCS file: /cvsroot/todo-manager/todo-manager/main.py,v retrieving revision 1.75 retrieving revision 1.76 diff -u -d -r1.75 -r1.76 --- main.py 26 Apr 2003 20:19:58 -0000 1.75 +++ main.py 26 Apr 2003 22:08:13 -0000 1.76 @@ -49,6 +49,7 @@ _new_file = FALSE _load_file = None _load_config = TRUE +_load_plugins = TRUE help_file = os.path.join(get_root_directory(), 'docs', 'index.html') @@ -94,7 +95,7 @@ if _load_config: self.__load_config() - if self.get_setting("Core", "loadplugins", TRUE): + if self.get_setting("Core", "loadplugins", TRUE) and _load_plugins: # Get the plugins in the root directory plgs = [os.path.join(get_root_directory(), 'plugins')] @@ -704,17 +705,10 @@ self.interface_call(interface, "update_list_groups", self.__get_task_groups()) # Plugins that are loaded - if self.get_setting("Core", "loadplugins", TRUE): - for p in plugin._loaded_plugins: - a = p.copy() - del a['function'] - - # If it's a sorting or filter plugin don't pass the plugin value - # The interface should call 'set_ui_sorting_filter' instead - if (a['type'] == "task_sorting") or (a['type'] == "task_filter"): - del a['value'] + plgs = self.get_plugin_info() - self.interface_call(interface, "add_plugin", a) + for p in plgs: + self.interface_call(interface, "add_plugin", p) # The interface was bound successfully return TRUE @@ -864,18 +858,20 @@ def get_plugin_info(self): """Return information on all available plugins""" - # Get the plugins in the root directory - paths = [os.path.join(get_root_directory(), 'plugins')] + if self.get_setting("Core", "loadplugins", TRUE) and _load_plugins: + plgs = plugin._loaded_plugins + new_plgs = [] - # Get plugins from the user's directory - if get_user_directory() != get_root_directory(): - paths.append(os.path.join(get_user_directory(), 'plugins')) + for p in plgs: + a = p.copy() + del a['function'] - new_plgs = plugin.get_all_plugins(paths) + # If it's a sorting or filter plugin don't pass the plugin value + # The interface should call 'set_ui_sorting_filter' instead + if (a['type'] == "task_sorting") or (a['type'] == "task_filter"): + del a['value'] - # Remove function references - for p in new_plgs: - del p['function'] + new_plgs.append(a) return new_plgs @@ -1106,6 +1102,7 @@ OPTIONS: -N\t\t\t:Startup with a new blank file. -I\t\t\t:Don't load the configuration file. + -P\t\t\t:Don't load plugins. --help, -h\t\t:Display this text and exit. --version, -v\t\t:Display the version number and exit. """) @@ -1113,7 +1110,7 @@ # The wheels on the bus go round and round def parse_args(args): # Parsing the command arguments - global _load_file, _load_config, _new_file + global _load_file, _load_config, _load_plugins, _new_file for arg in args: if arg == "--help": @@ -1131,8 +1128,9 @@ elif a == "v": print "%s - %s" %(appname, version) return FALSE - elif a == "N": _new_file = not _new_file - elif a == "I": _load_config = not _load_config + elif a == 'N': _new_file = not _new_file + elif a == 'I': _load_config = not _load_config + elif a == 'P': _load_plugins = not _load_plugins elif os.path.isfile(arg): arg = os.path.join(os.getcwd(), arg) _load_file = arg Index: plugin.py =================================================================== RCS file: /cvsroot/todo-manager/todo-manager/plugin.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- plugin.py 18 Dec 2002 21:29:17 -0000 1.7 +++ plugin.py 26 Apr 2003 22:08:13 -0000 1.8 @@ -6,9 +6,12 @@ # # Architecture for loading plugins into ToDo Manager +from __init__ import * import os, imp import tdmcalls +_ = get_translation('core') + plugin_module = None # This holds all of the plugins that are loaded @@ -35,7 +38,11 @@ # Plugin functions def get_plugin_from_file(file): - mod = imp.load_source(os.path.splitext(file)[0], file) + try: + mod = imp.load_source(os.path.splitext(file)[0], file) + except: + print _("Unable to load plugin from file: %s" %file) + return None # If the plugin_module is set, then tell the new plugin if plugin_module: |