def _get_method_result(module_, module_instance, method_name, method_arg=None):
 log.debug('Trying to call %s on %s', method_name, module_)
 try:
  method_obj = getattr(module_, method_name)
 except AttributeError:
  try:
   method_obj = getattr(module_instance, method_name)
  except AttributeError:
   raise InvalidArgumentError('The {0} module does not have any property or method named {1}'.format(module_, method_name))
 if isinstance(method_obj, property):
  return method_obj.fget(module_instance)
 elif isinstance(method_obj, (types.MethodType, types.FunctionType)):
  if (not method_arg):
   raise InvalidArgumentError('{0} is a method of the {1} module. An argument dict is required.'.format(method_name, module_))
  try:
   return getattr(module_instance, method_name)(method_arg['parameter'])
  except KeyError:
   raise InvalidArgumentError('The argument dict supplied has no key named "parameter": {0}'.format(method_arg))
  except AttributeError:
   raise InvalidArgumentError('The {0} module does not have any property or method named {1}'.format(module_, method_name))
 else:
  return method_obj
 return None

def _get_method_result ( module_ , module_instance , method_name , method_arg = None ) : log . debug ( 'Trying to call %s on %s' , method_name , module_ ) try : method_obj = getattr ( module_ , method_name ) except AttributeError : try : method_obj = getattr ( module_instance , method_name ) except AttributeError : raise InvalidArgumentError ( 'The {0} module does not have any property or method named {1}' . format ( module_ , method_name ) ) if isinstance ( method_obj , property ) : return method_obj . fget ( module_instance ) elif isinstance ( method_obj , ( types . MethodType , types . FunctionType ) ) : if ( not method_arg ) : raise InvalidArgumentError ( '{0} is a method of the {1} module. An argument dict is required.' . format ( method_name , module_ ) ) try : return getattr ( module_instance , method_name ) ( method_arg [ 'parameter' ] ) except KeyError : raise InvalidArgumentError ( 'The argument dict supplied has no key named "parameter": {0}' . format ( method_arg ) ) except AttributeError : raise InvalidArgumentError ( 'The {0} module does not have any property or method named {1}' . format ( module_ , method_name ) ) else : return method_obj return None
given a testinfra module object .