Eliminated last remaining eval calls. Fixes #705346

This commit is contained in:
Mathieu Comandon 2011-03-06 18:40:08 +01:00
parent 3d22b98e52
commit b5cc535f76
3 changed files with 20 additions and 26 deletions

View file

@ -20,24 +20,24 @@
###############################################################################
import gtk
import lutris.runners
from lutris.runners import import_runner
from lutris.gui.configvbox import ConfigVBox
class InstallerConfigVBox(ConfigVBox):
"""This file is going to disapear anytime now."""
def __init__(self,lutris_config,caller):
ConfigVBox.__init__(self,"game",caller)
self.lutris_config = lutris_config
self.lutris_config.config_type = "game"
self.runner_class = self.lutris_config.runner
runner = eval("lutris.runners."+self.runner_class+"."+self.runner_class+"()")
self.runner_classname = self.lutris_config.runner
runner_cls = import_runner(self.runner_classname)
runner = runner_cls()
if hasattr(runner,"installer_options"):
self.options = runner.installer_options
else:
no_option_label = gtk.Label("No game options")
self.pack_start(no_option_label)
return
return
self.generate_widgets()

View file

@ -20,8 +20,7 @@
###############################################################################
import gtk
import lutris.runners
from lutris.runners import import_runner
from lutris.gui.configvbox import ConfigVBox
class RunnerConfigVBox(ConfigVBox):
@ -30,14 +29,12 @@ class RunnerConfigVBox(ConfigVBox):
runner configuration.
"""
def __init__(self, lutris_config, caller):
runner = lutris_config.runner
ConfigVBox.__init__(self, runner, caller)
# FIXME ugly
runner_instance = eval("lutris.runners."+runner+"."+runner+"()")
if hasattr(runner_instance, "runner_options"):
self.options = runner_instance.runner_options
runner_classname = lutris_config.runner
ConfigVBox.__init__(self, runner_classname, caller)
runner_class = import_runner(runner_classname)
runner = runer_class()
if hasattr(runner, "runner_options"):
self.options = runner.runner_options
self.lutris_config = lutris_config
self.generate_widgets()
else:

View file

@ -21,8 +21,7 @@
import gtk
import lutris.runners
from lutris.runners import import_runner
from lutris.config import LutrisConfig
from lutris.gui.runnerconfigvbox import RunnerConfigVBox
from lutris.gui.systemconfigvbox import SystemConfigVBox
@ -91,11 +90,8 @@ class RunnersDialog(gtk.Dialog):
for runner in runner_list:
hbox = gtk.HBox()
#Label
runner_module = __import__('lutris.runners.%s' % runner,
globals(), locals(), [runner], -1)
runner_cls = getattr(runner_module, runner)
runner_instance = runner_cls()
#runner_instance = eval("lutris.runners." + runner + "." + runner + "()")
runner_class = import_runner(runner)
runner_instance = runner_class()
machine = runner_instance.machine
runner_label = gtk.Label()
runner_label.set_markup("<b>"+runner + "</b> ( " + machine + " ) ")
@ -125,11 +121,12 @@ class RunnersDialog(gtk.Dialog):
def close(self, widget=None, other=None):
self.destroy()
def on_install_clicked(self,widget,runner):
def on_install_clicked(self,widget,runner_classname):
"""Install a runner"""
#FIXME : this is ugly !
runner_instance = eval("lutris.runners." + runner + "." + runner + "()")
runner_instance.install()
runner_class = import_runner(runner_classname)
runner = runner_classname()
runner.install()
def on_configure_clicked(self,widget,runner):
RunnerConfigDialog(runner)