
    (                        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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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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KJr   " S S\R8                  5      r " S S\5      r " S S\5      r " S S\R>                  5      r  " S S \RB                  5      r" " S! S"\RB                  5      r# " S# S$\RH                  5      r% " S% S&\RB                  5      r& " S' S(\RB                  5      r'0 \RP                  \RR                  _\RT                  \RV                  _\RX                  \ _\RZ                  \R\                  _\R^                  \"_\R`                  \RH                  _\Rb                  \Rd                  _\Rf                  \Rh                  _\Rj                  \Rl                  _\Rn                  \&_\Rp                  \#_\Rr                  \Rt                  _\Rv                  \Rx                  _\Rz                  \%_\R|                  \R~                  _\R                  \R>                  _rA0 rBS) rCS/S* jrDS+ rES0S- jrFS1S. jrGg,)2a  Methods for formatting and printing Python objects.

Each printer has three main attributes, all accessible as strings in the
--format='NAME[ATTRIBUTES](PROJECTION)' option:

  NAME: str, The printer name.

  [ATTRIBUTES]: str, An optional [no-]name[=value] list of attributes. Unknown
    attributes are silently ignored. Attributes are added to a printer local
    dict indexed by name.

  (PROJECTION): str, List of resource names to be included in the output
    resource. Unknown names are silently ignored. Resource names are
    '.'-separated key identifiers with an implicit top level resource name.

Example:

  gcloud compute instances list \
      --format='table[box](name, networkInterfaces[0].networkIP)'
    )absolute_import)division)unicode_literals)
exceptions)log)
properties)config_printer)csv_printer)diff_printer)flattened_printer)json_printer)list_printer)object_printer)resource_lex)resource_printer_base)resource_printer_types)resource_projection_spec)resource_property)resource_transform)table_printer)yaml_printerc                       \ rS rSrSrSrg)Error=   zExceptions for this module. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       4lib/googlecloudsdk/core/resource/resource_printer.pyr   r   =   s    #r#   r   c                       \ rS rSrSrSrg)UnknownFormatErrorA   zUnknown format name exception.r   Nr   r   r#   r$   r&   r&   A   s    &r#   r&   c                       \ rS rSrSrSrg)ProjectionFormatRequiredErrorE   z1Projection key missing required format attribute.r   Nr   r   r#   r$   r)   r)   E   s    9r#   r)   c                       \ rS rSrSrSrg)DefaultPrinterI   z}An alias for YamlPrinter.

An alias for the *yaml* format. To override use *gcloud config set
core/default_format* property.
r   Nr   r   r#   r$   r,   r,   I   s    r#   r,   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )DisablePrinterQ   zDisables formatted output and does not consume the resources.

Disables formatted output and does not consume the resources. Equivalent to
the *none* format, but also short-circuits early for commands that return
pageable lists.
c                 @   > [         [        U ]
  " U0 UD6  SS0U l        g )Ndisable   )superr/   __init__
attributes)selfargskwargs	__class__s      r$   r5   DisablePrinter.__init__Y   s"    	.$($9&9 !nDOr#   )r6   )r   r   r   r    r!   r5   r"   __classcell__r:   s   @r$   r/   r/   Q   s    % %r#   r/   c                       \ rS rSrSrSrg)NonePrinter^   zmDisables formatted output and consumes the resources.

Disables formatted output and consumes the resources.
r   Nr   r   r#   r$   r?   r?   ^       r#   r?   c                       \ rS rSrSrSrg)TextPrintere   zEAn alias for FlattenedPrinter.

An alias for the *flattened* format.
r   Nr   r   r#   r$   rC   rC   e   rA   r#   rC   c                   6   ^  \ rS rSrSrU 4S jrSS jrSrU =r$ )MultiPrinterl   a  A printer that prints different formats for each projection key.

Each projection key must have a subformat defined by the
:format=FORMAT-STRING attribute. For example,

  `--format="multi(data:format=json, info:format='table[box](a, b, c)')"`

formats the *data* field as JSON and the *info* field as a boxed table.

Printer attributes:
  separator: Separator string to print between each format. If multiple
    resources are provided, the separator is also printed between each
    resource.
c           	        > [         [        U ]
  " U0 UD6  / U l        U R                  R                  5        H  nUR                  R                  (       d6  [        SR                  [        R                  " UR                  5      S95      eU R                  R                  U[        UR                  R                  U R                  S945        M     g )Nz {key} requires format attribute.)key)out)r4   rF   r5   columnscolumn_attributesColumns	attribute	subformatr)   formatr   
GetKeyNamerI   appendPrinter_out)r7   r8   r9   colr:   s       r$   r5   MultiPrinter.__init__|   s    	,&77DL%%--/]]$$+.55 ++CGG4 6 67 	7 ll//TYY?
@B 0r#   c                    U R                   R                  SS5      n[        U R                  5       H_  u  nu  pVUS:w  d  U(       a  U R                  R                  U5        UR                  [        R                  " XR                  5      5        Ma     U R                   R                  SS5      nU(       a  U R                  R                  U5        g g )N	separator r   
terminator)
r6   get	enumeraterK   rT   writePrintr   GetrI   )r7   recorddelimitrX   irU   printerrZ   s           r$   
_AddRecordMultiPrinter._AddRecord   s    ##K4I&t||4>C	
a7			"mm%))&'':; 5 $$\26J
iiooj! r#   )rK   )T)	r   r   r   r    r!   r5   rd   r"   r<   r=   s   @r$   rF   rF   l   s    B" "r#   rF   c                       \ rS rSrSrSrg)PrinterAttributes   a
  Attributes for all printers. This docstring is used to generate topic docs.

All formats have these attributes.

Printer attributes:
  disable: Disables formatted output and does not consume the resources.
  json-decode: Decodes string values that are JSON compact encodings of list
    and dictionary objects. This may become the default.
  pager: If True, sends output to a pager.
  private: Disables log file output. Use this for sensitive resource data
    that should not be displayed in log files. Explicit command line IO
    redirection overrides this attribute.
  transforms: Apply projection transforms to the resource values. The default
    is format specific; table-like formats may define default transforms to
    certain columns. Use *no-transforms* to disable.
r   Nr   r   r#   r$   rg   rg      s    r#   rg   c                 (    U[         U '   S[        U '   g )NT_FORMATTERS_HIDDEN_FORMATTERS)format_namerc   s     r$   RegisterFormatterrn      s    $+k$([!r#   c                 p    [          Vs0 s H   nU (       d  U[        ;  d  M  U[         U   _M"     sn$ s  snf )zReturns the (format-name => Printer) format registry dictionary.

Args:
  hidden: bool, if True, include the hidden formatters.

Returns:
  The (format-name => Printer) format registry dictionary.
rj   )hiddenrm   s     r$   GetFormatRegistryrq      sH     
J
 5@;6H#H 0+{;/
/

J J 
Js   33c                       [        [        5      $ )z0Returns a sorted list of supported format names.)sortedrk   r   r#   r$   SupportedFormatsrt      s    		r#   Nc           	         SSK Jn  [        R                  R                  R
                  R                  5       nU R                  [        R                  5      (       a
  U(       a  UnOU n[        R                  " SR                  U5      5        UR                  U[        R                  " U[         R"                  " 5       S9S9nUR%                  5       R'                  5       nU(       d  g [(        U   n	U	" UU[2        UUS	9n
U
$ ! [*         a3    [-        SR                  SR/                  [1        5       5      U5      5      ef = f)
a*  Returns a resource printer given a format string.

Args:
  print_format: The _FORMATTERS name with optional attributes and projection.
  out: Output stream, log.out if None.
  defaults: Optional resource_projection_spec.ProjectionSpec defaults.
  console_attr: The console attributes for the output stream. Ignored by some
    printers. If None then printers that require it will initialize it to
    match out.

Raises:
  UnknownFormatError: The print_format is invalid.

Returns:
  An initialized ResourcePrinter class or None if printing is disabled.
r   )resource_projectorzChosen display Format:{})defaultssymbols)
expressionrw   NzhFormat must be one of {0}; received [{1}].

For information on output formats:
  $ gcloud topic formats
z, )rJ   namerc   	projectorconsole_attr)googlecloudsdk.core.resourcerv   core_propertiesVALUEScoredefault_formatr_   endswithformatsDEFAULTr   debugrP   Compiler   ProjectionSpecr   GetTransforms
ProjectionNamerk   KeyErrorr&   joinrt   rS   )print_formatrJ   rw   r|   rv   default_format_propertychosen_print_formatr{   printer_nameprinter_classrc   s              r$   rS   rS      s+   $ > ,2277FFJJL 7??++0G1&))&--.ABC (($'66%7%E%E%G ) ) %%',,.,	9-M c+")$-'3	5'
 
. 
 9
 
 F499%'(,79 99s   +	D =Ec                 J    [        XUS9nU(       a  UR                  X5        gg)a  Prints the given resources.

Args:
  resources: A singleton or list of JSON-serializable Python objects.
  print_format: The _FORMATTER name with optional projection expression.
  out: Output stream, log.out if None.
  defaults: Optional resource_projection_spec.ProjectionSpec defaults.
  single: If True then resources is a single item and not a list.
    For example, use this to print a single object as JSON.
)rJ   rw   N)rS   r^   )	resourcesr   rJ   rw   singlerc   s         r$   r^   r^     s$     LH='MM)$ r#   )F)NNN)NNF)Hr!   
__future__r   r   r   googlecloudsdk.corer   core_exceptionsr   r   r~   r}   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r&   r)   YamlPrinterr,   ResourcePrinterr/   r?   FlattenedPrinterrC   rF   rg   CONFIGConfigPrinterCSV
CsvPrinterr   DIFFDiffPrinterDISABLE	FLATTENEDGET
GetPrinterJSONJsonPrinterLISTListPrinterMULTINONEOBJECTObjectPrinterTABLETablePrinterTEXTVALUEValuePrinterYAMLrk   rl   rn   rq   rt   rS   r^   r   r#   r$   <module>r      sR   * '  ' = # = 7 4 5 : 5 5 7 5 > J A : ; 6 5$O!! $' ':E :\-- 
%*:: 
%'77 #44 %"(88 %"P-== &NNN00KK'' OO^ LL,**	
 OO^ (99 KK'' LL,** LL,** MM< LL+ NNN00 MM=-- LL+ MM;++  LL,**!&  )

J6r%r#   