
                         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\5      rg)	z6Resource display info for the Calliope display module.    )absolute_import)division)unicode_literals)cache_update_opsc                       \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rSrg)DisplayInfo   a  Display info accumulator for priming Displayer.

"legacy" logic will be dropped when the incremental Command class refactor
is complete.

NOTICE: If you add an attribute:
  (1) document it
  (2) handle it in AddLowerDisplayInfo()

Attributes:
  cache_updater: A resource_cache.Updater class that will be instantiated and
    called to update the cache to reflect the resources returned by the
    calling command.
  filter: The default filter string. args.filter takes precedence.
  flatten: The default flatten string. args.flatten takes precedence.
  format: The default format string. args.format takes precedence.
  transforms: The filter/format transforms symbol dict.
  aliases: The resource name alias dict.
c                 X    S U l         S U l        S U l        S U l        0 U l        0 U l        g N)_cache_updater_filter_format_flatten_transforms_aliasesselfs    +lib/googlecloudsdk/calliope/display_info.py__init__DisplayInfo.__init__-   s.    DDLDLDMDDM    c                 2   U R                   (       d  UR                  U l         U R                  (       d  UR                  U l        U R                  (       d  UR
                  U l        U R                  (       d  UR                  U l        UR                  (       a6  [        UR                  5      nUR                  U R                  5        X l        UR                  (       a7  [        UR                  5      nUR                  U R                  5        X0l        gg)zAdd lower precedence display_info to the object.

This method is called by calliope to propagate CLI low precedence parent
info to its high precedence children.

Args:
  display_info: The low precedence DisplayInfo object to add.
N)r   cache_updaterr   filterr   formatr   flatten
transformsdictupdater   aliasesr   )r   display_infor   r    s       r   AddLowerDisplayInfoDisplayInfo.AddLowerDisplayInfo6   s     (66d<<!((dl<<!((dl=="**dm//0j(#\))*gnnT]]#m r   c                      U(       a  Xl         gg)zAdds a format to the display info, newer info takes precedence.

Args:
  format: The default format string. args.format takes precedence.
Nr   )r   r   s     r   	AddFormatDisplayInfo.AddFormatP        l r   c                      U(       a  Xl         gg)a  Adds a flatten to the display info, newer info takes precedence.

Args:
  flatten: [str], The list of flatten strings to use by default; e.g.
    ['fieldA.fieldB', 'fieldC.fieldD']. Flatten strings provided by
    args.flatten take precedence if the --flatten flag is specified.
Nr   )r   r   s     r   
AddFlattenDisplayInfo.AddFlattenY   s     m r   c                      U(       a  Xl         gg)zAdds a filter to the display info, newer info takes precedence.

Args:
  filter: The default filter string. args.filter takes precedence.
Nr   )r   r   s     r   	AddFilterDisplayInfo.AddFilterd   r(   r   c                 J    U(       a  U R                   R                  U5        gg)zAdds transforms to the display info, newer values takes precedence.

Args:
  transforms: A filter/format transforms symbol dict.
N)r   r   )r   r   s     r   AddTransformsDisplayInfo.AddTransformsm   s      
j) r   c                 <   ^ SU4S jjnU R                  SU05        g)zAdds a uri transform to the display info using uri_func.

Args:
  uri_func: func(resource), A function that returns the uri for a resource
    object.
Nc                 X   >  T" U 5      =(       d    U$ ! [         [        4 a    Us $ f = fr   )AttributeError	TypeError)resource	undefineduri_funcs     r   _TransformUri-DisplayInfo.AddUriFunc.<locals>._TransformUri~   s2    !.Y.i( s    ))urir   )r2   )r   r:   r;   s    ` r   
AddUriFuncDisplayInfo.AddUriFuncv   s     	}-.r   c                 J    U(       a  U R                   R                  U5        gg)a#  Adds aliases to the display info, newer values takes precedence.

Args:
  aliases: {str: parsed_key} The resource name alias dict that maps short
    names to parsed keys. The parsed key for 'abc.xyz' is ['abc', 'xyz'].
    See the resource_lex.Lexer.Key() docstring for parsed key details.
N)r   r   )r   r    s     r   
AddAliasesDisplayInfo.AddAliases   s     
mm7# r   c                 @    U=(       d    [         R                  U l        g)a  Adds a cache_updater to the display info, newer values takes precedence.

The cache updater is called to update the resource cache for CreateCommand,
DeleteCommand and ListCommand commands.

Args:
  cache_updater: A resource_cache.Updater class that will be instantiated
    and called to update the cache to reflect the resources returned by the
    calling command. None disables cache update.
N)r   NoCacheUpdaterr   )r   r   s     r   AddCacheUpdaterDisplayInfo.AddCacheUpdater   s     (J+;+J+JDr   c                     U R                   $ r   )r   r   s    r   r   DisplayInfo.cache_updater   s    r   c                     U R                   $ r   r%   r   s    r   r   DisplayInfo.format       <<r   c                     U R                   $ r   r*   r   s    r   r   DisplayInfo.flatten       ==r   c                     U R                   $ r   r.   r   s    r   r   DisplayInfo.filter   rK   r   c                     U R                   $ r   )r   r   s    r   r    DisplayInfo.aliases   rN   r   c                     U R                   $ r   )r   r   s    r   r   DisplayInfo.transforms   s    r   )r   r   r   r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r"   r&   r+   r/   r2   r>   rA   rE   propertyr   r   r   r   r    r   __static_attributes__ r   r   r   r      s    (4	*/ 	$K            r   r   N)	rY   
__future__r   r   r   googlecloudsdk.core.cacher   objectr   r\   r   r   <module>r`      s$    = &  ' 6\& \r   