def _is_image_available(context, image):
 if (hasattr(context, 'auth_token') and context.auth_token):
  return True
 def _is_image_public(image):
  if hasattr(image, 'visibility'):
   return (str(image.visibility).lower() == 'public')
  else:
   return image.is_public
 if (context.is_admin or _is_image_public(image)):
  return True
 properties = image.properties
 if (context.project_id and ('owner_id' in properties)):
  return (str(properties['owner_id']) == str(context.project_id))
 if (context.project_id and ('project_id' in properties)):
  return (str(properties['project_id']) == str(context.project_id))
 try:
  user_id = properties['user_id']
 except KeyError:
  return False
 return (str(user_id) == str(context.user_id))

def _is_image_available ( context , image ) : if ( hasattr ( context , 'auth_token' ) and context . auth_token ) : return True def _is_image_public ( image ) : if hasattr ( image , 'visibility' ) : return ( str ( image . visibility ) . lower ( ) == 'public' ) else : return image . is_public if ( context . is_admin or _is_image_public ( image ) ) : return True properties = image . properties if ( context . project_id and ( 'owner_id' in properties ) ) : return ( str ( properties [ 'owner_id' ] ) == str ( context . project_id ) ) if ( context . project_id and ( 'project_id' in properties ) ) : return ( str ( properties [ 'project_id' ] ) == str ( context . project_id ) ) try : user_id = properties [ 'user_id' ] except KeyError : return False return ( str ( user_id ) == str ( context . user_id ) )
check image availability .