From 875f2183793c7d47cf9c59b05a66b9900bb9de2a Mon Sep 17 00:00:00 2001 From: Worros Date: Sat, 14 Mar 2009 04:23:36 +0900 Subject: [PATCH] Move it back again, found another way --- pyfpdb/Hud.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 3df3781a..c9e0ea07 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -46,6 +46,16 @@ import Database import HUD_main import Utils +def importName(module_name, name, params): + """Import a named object 'name' from module 'module_name'.""" +# Recipe 16.3 in the Python Cookbook, 2nd ed. Thanks!!!! +# Modded by Carl G to support additional params + try: + module = __import__(module_name, globals(), locals(), [name]) + except: + return None + return(getattr(module, name)) + class Hud: def __init__(self, parent, table, max, poker_game, config, db_connection): @@ -80,7 +90,7 @@ class Hud: if not game_params['aux'] == [""]: for aux in game_params['aux']: aux_params = config.get_aux_parameters(aux) - my_import = Utils.importName(aux_params['module'], aux_params['class']) + my_import = importName(aux_params['module'], aux_params['class']) if my_import == None: continue self.aux_windows.append(my_import(self, config, aux_params))