def get_or_create_mrjob_service_role(conn):
 for (role_name, role_document) in _yield_roles(conn):
  if (role_document != _MRJOB_SERVICE_ROLE):
   continue
  policy_arns = list(_yield_attached_role_policies(conn, role_name))
  if (policy_arns == [_EMR_SERVICE_ROLE_POLICY_ARN]):
   return role_name
 name = _create_mrjob_role_with_attached_policy(conn, _MRJOB_SERVICE_ROLE, _EMR_SERVICE_ROLE_POLICY_ARN)
 log.info(('Auto-created service role %s' % name))
 return name

def get_or_create_mrjob_service_role ( conn ) : for ( role_name , role_document ) in _yield_roles ( conn ) : if ( role_document != _MRJOB_SERVICE_ROLE ) : continue policy_arns = list ( _yield_attached_role_policies ( conn , role_name ) ) if ( policy_arns == [ _EMR_SERVICE_ROLE_POLICY_ARN ] ) : return role_name name = _create_mrjob_role_with_attached_policy ( conn , _MRJOB_SERVICE_ROLE , _EMR_SERVICE_ROLE_POLICY_ARN ) log . info ( ( 'Auto-created service role %s' % name ) ) return name
look for a usable service role for emr .