def get_action_class_instance(action_cls, config=None, action_service=None):
 kwargs = {}
 kwargs['config'] = config
 kwargs['action_service'] = action_service
 try:
  action_instance = action_cls(**kwargs)
 except TypeError as e:
  if ("unexpected keyword argument 'action_service'" not in str(e)):
   raise e
  LOG.debug(('Action class (%s) constructor doesn\'t take "action_service" argument, falling back to late assignment...' % action_cls.__class__.__name__))
  action_service = kwargs.pop('action_service', None)
  action_instance = action_cls(**kwargs)
  action_instance.action_service = action_service
 return action_instance

def get_action_class_instance ( action_cls , config = None , action_service = None ) : kwargs = { } kwargs [ 'config' ] = config kwargs [ 'action_service' ] = action_service try : action_instance = action_cls ( ** kwargs ) except TypeError as e : if ( "unexpected keyword argument 'action_service'" not in str ( e ) ) : raise e LOG . debug ( ( 'Action class (%s) constructor doesn\'t take "action_service" argument, falling back to late assignment...' % action_cls . __class__ . __name__ ) ) action_service = kwargs . pop ( 'action_service' , None ) action_instance = action_cls ( ** kwargs ) action_instance . action_service = action_service return action_instance
instantiate and return action class instance .