def get_class_and_baseclass_names(self): """Returns both the name of the Python class for this install path and the name of its base class""" suffix = ''.join([n[0].upper() + n[1:] for n in self._intermediate_names]) class_prefix = entity_type_to_class_name(self.entity_type) + suffix baseclass_prefix = entity_type_to_baseclass_name(self.entity_type) if baseclass_prefix != "CommandInstallable": baseclass_prefix += suffix return class_prefix, baseclass_prefix
def create_function(loadable_class, command_def, execute_command_function=None): """Creates the function which will appropriately call execute_command for this command""" execute_command = create_execute_command_function( command_def, execute_command_function) api_decorator = get_api_context_decorator( logging.getLogger(loadable_class.__module__)) if command_def.is_constructor: func_text = get_function_text( command_def, body_text=_get_init_body_text(command_def), decorator_text='@api') #print "func_text for %s = %s" % (command_def.full_name, func_text) dependencies = { 'api': api_decorator, 'base_class': _installable_classes_store.get( entity_type_to_baseclass_name(command_def.install_path.full), CommandInstallable), EXECUTE_COMMAND_FUNCTION_NAME: execute_command } else: func_text = get_function_text( command_def, body_text='return ' + get_call_execute_command_text(command_def), decorator_text='@api') dependencies = { 'api': api_decorator, EXECUTE_COMMAND_FUNCTION_NAME: execute_command } try: function = _compile_function(command_def.name, func_text, dependencies) except: sys.stderr.write( "Metaprogramming problem compiling %s for class %s in code: %s" % (command_def.full_name, loadable_class.__name__, func_text)) raise function.command = command_def function.__doc__ = get_spa_docstring(command_def) return function
def create_function(loadable_class, command_def, execute_command_function=None): """Creates the function which will appropriately call execute_command for this command""" execute_command = create_execute_command_function(command_def, execute_command_function) if command_def.is_constructor: func_text = get_function_text(command_def, body_text=_get_init_body_text(command_def)) # print "func_text for %s = %s" % (command_def.full_name, func_text) dependencies = {'base_class': _installable_classes_store.get(entity_type_to_baseclass_name(command_def.install_path.full), CommandInstallable), EXECUTE_COMMAND_FUNCTION_NAME: execute_command} else: func_text = get_function_text(command_def, body_text='return ' + get_call_execute_command_text(command_def)) dependencies = {EXECUTE_COMMAND_FUNCTION_NAME: execute_command} try: function = _compile_function(command_def.name, func_text, dependencies) except: sys.stderr.write("Metaprogramming problem compiling %s for class %s in code: %s" % (command_def.full_name, loadable_class.__name__, func_text)) raise function.command = command_def function.__doc__ = get_spa_docstring(command_def) api_decorator = get_api_context_decorator(logging.getLogger(loadable_class.__module__)) return api_decorator(function)