Ignore:
Timestamp:
09/03/13 21:45:56 (8 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
Phase:
public
Rebase:
66313336306139663137353133343631633733646335393536643436373233653030303733653563
Message:

Drop compatibility imports, and allow an optional module on classnames

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/level.py

    r201 r209  
    7373
    7474    def _create_game_object(self, space, classname, args, name=None):
    75         # We should probably build a registry of game objects or something.
    76         # At least this is better than just calling `eval`, right?
    77         cls = getattr(go, classname)
     75        modules = {
     76            'game_object': go,
     77            'puzzle': puzzle,
     78        }
     79        if '.' in classname:
     80            module, classname = classname.split('.')
     81        else:
     82            module = 'game_object'
     83        cls = getattr(modules[module], classname)
     84
    7885        if issubclass(cls, puzzle.Puzzler):
    7986            gobj = cls(*args)
Note: See TracChangeset for help on using the changeset viewer.