
    |                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ	 ddl
mZ ddlZ G d	 d
ej                        Zd Zd Zy)z/Utilities for Data Catalog taxonomies commands.    )absolute_import)division)unicode_literals)encoding)util)
exceptionsNc                       e Zd ZdZy)InvalidInlineSourceErrorz1Error if a inline source is improperly specified.N)__name__
__module____qualname____doc__     >lib/googlecloudsdk/command_lib/data_catalog/taxonomies/util.pyr
   r
      s    9r   r
   c                 ,   t        j                  |      }|dk(  r|j                  }n|j                  }	 t	        j
                  d| i|      }t        |      }|r"dg}||z  }t        dj                  |            |S # t        $ r t        d      w xY w)ak  Converts the given inline source dict to the corresponding import request.

  Args:
    inline_source: dict, inlineSource part of the import taxonomy request.
    version_label: string, specifies the version for client.
  Returns:
    GoogleCloudDatacatalogV1beta1ImportTaxonomiesRequest
  Raises:
    InvalidInlineSourceError: If the inline source is invalid.
  v1inlineSourcezVAn error occurred while parsing the serialized taxonomy. Please check your input file.z=Invalid inline source, the following fields are unrecognized:
)
api_utilGetMessagesModule/GoogleCloudDatacatalogV1ImportTaxonomiesRequest4GoogleCloudDatacatalogV1beta1ImportTaxonomiesRequestr   DictToMessageAttributeErrorr
   _GetUnrecognizedFieldPathsjoin)inline_sourceversion_labelmessagesrequestimport_request_messageunrecognized_field_pathserror_msg_liness          r   ProcessTaxonomiesFromYAMLr%      s     ''6(dFFGKKG2%33	' 88NO' (O//O
"499_#=
>>	 
 2
" $1 2 22s   A> >Bc                     t        j                  |       }g }|D ]E  \  }}dj                  d |D              }|D ]#  }|j                  dj	                  ||             % G t        |      S )z?Returns the field paths for unrecognized fields in the message..c              3   F   K   | ]  }t        j                  |        y w)N)six	text_type).0es     r   	<genexpr>z-_GetUnrecognizedFieldPaths.<locals>.<genexpr>F   s     !M<Lq#--"2<Ls   !z{}.{})r   UnrecognizedFieldIterr   appendformatsorted)messageerrorsr#   edges_to_messagefield_namesmessage_field_path
field_names          r   r   r   A   st    ))'2&'-#!M<L!MM!
%%gnn
j'* + " (.
 
(	))r   )r   
__future__r   r   r   apitools.base.pyr   #googlecloudsdk.api_lib.data_catalogr   r   googlecloudsdk.corer   r)   Errorr
   r%   r   r   r   r   <module>r=      s<    6 &  ' % @ * 
:z// : D	*r   