
    >	                         d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlm	Z	 ddl
mZ d	Z G d
 de	j                        Z G d de      Z G d de      Zd Zy)z&Flags for gcloud ml language commands.    )absolute_import)division)unicode_literalsN)storage_util)
exceptions)fileslanguagec                       e Zd ZdZy)ErrorzExceptions for this module.N__name__
__module____qualname____doc__     2lib/googlecloudsdk/command_lib/ml/language/util.pyr   r       s    #r   r   c                       e Zd ZdZy)ContentFileErrorz8Error if content file can't be read and isn't a GCS URL.Nr   r   r   r   r   r   $   s    @r   r   c                       e Zd ZdZy)ContentErrorzError if content is not given.Nr   r   r   r   r   r   (   s    &r   r   c                    |j                   }|j                  }|j                  }|r|rt        d      t        j
                  j                  |      rt        j                  |      |_         |S t        j                  j                  |      r	||_        |S t        dj                  |            |r	||_         |S t        d      )zEThe Python hook for yaml commands to inject content into the request.z]Either a file or content must be provided for analysis by the Natural Language API, not both.zCould not find --content-file [{}]. Content file must be a path to a local file or a Google Cloud Storage URL (format: `gs://bucket_name/object_name`)zJThe content provided is empty. Please provide language content to analyze.)contentcontent_filedocument
ValueErrorospathisfiler   ReadFileContentsr   ObjectReferenceIsStorageUrlgcsContentUrir   formatr   )
unused_refargsrequestr   r   r   s         r   UpdateRequestWithInputr(   ,   s    LL'"",( I J J	ww~~l#//=h 
. 
	%	%	2	2<	@+h 
. ,,2F<,@B B H 
.  6 7 7r   )r   
__future__r   r   r   r   googlecloudsdk.api_lib.storager   googlecloudsdk.corer   googlecloudsdk.core.utilr   LANGUAGE_APIr   r   r   r(   r   r   r   <module>r.      sW     - &  ' 	 7 * * $J $Au A'5 'r   