def get_user_program_credentials(user):
 programs_credentials_data = []
 credential_configuration = CredentialsApiConfig.current()
 if (not credential_configuration.is_learner_issuance_enabled):
  log.debug(u'Display of certificates for programs is disabled.')
  return programs_credentials_data
 credentials = get_user_credentials(user)
 if (not credentials):
  log.info(u'No credential earned by the given user.')
  return programs_credentials_data
 programs_credentials = []
 for credential in credentials:
  try:
   if (u'program_uuid' in credential[u'credential']):
    programs_credentials.append(credential)
  except KeyError:
   log.exception(u'Invalid credential structure: %r', credential)
 if programs_credentials:
  programs_credentials_data = get_programs_for_credentials(user, programs_credentials)
 return programs_credentials_data

def get_user_program_credentials ( user ) : programs_credentials_data = [ ] credential_configuration = CredentialsApiConfig . current ( ) if ( not credential_configuration . is_learner_issuance_enabled ) : log . debug ( u'Display of certificates for programs is disabled.' ) return programs_credentials_data credentials = get_user_credentials ( user ) if ( not credentials ) : log . info ( u'No credential earned by the given user.' ) return programs_credentials_data programs_credentials = [ ] for credential in credentials : try : if ( u'program_uuid' in credential [ u'credential' ] ) : programs_credentials . append ( credential ) except KeyError : log . exception ( u'Invalid credential structure: %r' , credential ) if programs_credentials : programs_credentials_data = get_programs_for_credentials ( user , programs_credentials ) return programs_credentials_data
given a user .