
    	                     n    S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr   " S S\R                  5      r
g	)
#Refine server response for display.    )absolute_import)division)unicode_literals)encoding)utilc                   b   ^  \ rS rSrSrU 4S jr\S 5       r\S 5       r\S 5       r	S r
SrU =r$ )	DisplayHelper   r   c                 `   > [         [        U ]  [        R                  " U5      5        Xl        g )N)superr
   __init__r   MessageToDict_job)selfjob	__class__s     5lib/googlecloudsdk/api_lib/dataproc/display_helper.pyr   DisplayHelper.__init__   s"    	-'(>(>s(CDI    c                 $    U R                  S5      $ )NJobgetTruncatedFieldNameBySuffixr   s    r   jobTypeDisplayHelper.jobType!   s    --e44r   c                 $    U R                  S5      $ )NBatchr   r   s    r   	batchTypeDisplayHelper.batchType%   s    --g66r   c                 $    U R                  S5      $ )NSessionr   r   s    r   sessionTypeDisplayHelper.sessionType)   s    --i88r   c                 X   U R                   R                  5        Vs/ s H  o"R                  PM     sn HT  nUR                  U5      (       d  M  UR	                  U5      u  n  nU R                   R                  U5      (       d  MR  Us  $    [        SR                  U5      5      es  snf )a   Get a field name by suffix and truncate it.

The one_of fields in server response have their type name as field key.
One can retrieve the name of those fields by iterating through all the
fields.

Args:
  suffix: the suffix to match.

Returns:
  The first matched truncated field name.

Raises:
  AttributeError: Error occur when there is no match for the suffix.

Usage Example:
  In server response:
  {
    ...
    "sparkJob":{
      ...
    }
    ...
  }
  type = helper.getTruncatedFieldNameBySuffix('Job')
z(Response has no field with {} as suffix.)r   
all_fieldsnameendswith
rpartitionget_assigned_valueAttributeErrorformat)r   suffixfieldtoken_s        r   r   +DisplayHelper.getTruncatedFieldNameBySuffix-   s    6 +/))*>*>*@A*@***@A			&&v.q!99''..,	 B
 C &.* * Bs   B')r   )__name__
__module____qualname____firstlineno____doc__r   propertyr   r    r$   r   __static_attributes____classcell__)r   s   @r   r
   r
      sQ    + 5 5 7 7 9 9!* !*r   r
   N)r7   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.dataprocr   Bunchr
    r   r   <module>r@      s)     * &  ' % 04*DJJ 4*r   