def _to_app_identity_error(error):
 error_map = {app_identity_service_pb.AppIdentityServiceError.NOT_A_VALID_APP: InternalError, app_identity_service_pb.AppIdentityServiceError.DEADLINE_EXCEEDED: BackendDeadlineExceeded, app_identity_service_pb.AppIdentityServiceError.BLOB_TOO_LARGE: BlobSizeTooLarge, app_identity_service_pb.AppIdentityServiceError.UNKNOWN_ERROR: InternalError, app_identity_service_pb.AppIdentityServiceError.UNKNOWN_SCOPE: InvalidScope, app_identity_service_pb.AppIdentityServiceError.NOT_ALLOWED: NotAllowed, app_identity_service_pb.AppIdentityServiceError.NOT_IMPLEMENTED: OperationNotImplemented}
 if (error.application_error in error_map):
  return error_map[error.application_error](error.error_detail)
 else:
  return InternalError(('%s: %s' % (error.application_error, error.error_detail)))

def _to_app_identity_error ( error ) : error_map = { app_identity_service_pb . AppIdentityServiceError . NOT_A_VALID_APP : InternalError , app_identity_service_pb . AppIdentityServiceError . DEADLINE_EXCEEDED : BackendDeadlineExceeded , app_identity_service_pb . AppIdentityServiceError . BLOB_TOO_LARGE : BlobSizeTooLarge , app_identity_service_pb . AppIdentityServiceError . UNKNOWN_ERROR : InternalError , app_identity_service_pb . AppIdentityServiceError . UNKNOWN_SCOPE : InvalidScope , app_identity_service_pb . AppIdentityServiceError . NOT_ALLOWED : NotAllowed , app_identity_service_pb . AppIdentityServiceError . NOT_IMPLEMENTED : OperationNotImplemented } if ( error . application_error in error_map ) : return error_map [ error . application_error ] ( error . error_detail ) else : return InternalError ( ( '%s: %s' % ( error . application_error , error . error_detail ) ) )
translate an application error to an external error .