diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 07396f61..3df3781a 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -43,16 +43,8 @@ import Configuration import Stats import Mucked import Database -import HUD_main - -def importName(module_name, name): - """Import a named object 'name' from module 'module_name'.""" -# Recipe 16.3 in the Python Cookbook, 2nd ed. Thanks!!!! - try: - module = __import__(module_name, globals(), locals(), [name]) - except: - return None - return(getattr(module, name)) +import HUD_main +import Utils class Hud: @@ -88,7 +80,7 @@ class Hud: if not game_params['aux'] == [""]: for aux in game_params['aux']: aux_params = config.get_aux_parameters(aux) - my_import = importName(aux_params['module'], aux_params['class']) + my_import = Utils.importName(aux_params['module'], aux_params['class']) if my_import == None: continue self.aux_windows.append(my_import(self, config, aux_params)) diff --git a/pyfpdb/Utils.py b/pyfpdb/Utils.py new file mode 100644 index 00000000..f7827451 --- /dev/null +++ b/pyfpdb/Utils.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Copyright 2009, Carl Gherardi +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +######################################################################## + +def importName(module_name, name): + """Import a named object 'name' from module 'module_name'.""" +# Recipe 16.3 in the Python Cookbook, 2nd ed. Thanks!!!! + try: + module = __import__(module_name, globals(), locals(), [name]) + except: + return None + return(getattr(module, name)) +