#!/usr/bin/env python """ menu/__init__.py - Emano Menu Class Author: Sean B. Palmer, inamidst.com Source: http://inamidst.com/emano/ """ class Menu(object): def __init__(self, editor): self.__editor = editor self.__commands = {} def __getattr__(self, attr): if attr.startswith('__'): return object.__getattr__(self, attr) if self.__commands.has_key(attr): return self.__commands[attr] module = getattr(__import__('menu.' + attr), attr) func = getattr(module, attr) def command(*args, **kargs): func(self.__editor, *args, **kargs) self.__commands[attr] = command return command if __name__=="__main__": main()