
    0                     r    S SK r S SKrS SKrS rS rS rS rS rS rSS jr	S	 r
S
 r " S S\5      rS rg)    Nc                      [         R                  " U [        R                  5        [        R                  R	                  S5        [        R                  R                  5         g)zWrite a message to standard output.

Args:
    **message: ({str: object, ...}) A JSON message encoded in keyword
        arguments.

N)jsondumpsysstdoutwriteflush)messages    'platform/ext-runtime/nodejs/lib/comm.py
_write_msgr      s8     	IIgszz"JJTJJ    c                     [        SX-  S9  g )Nerrortyper   r   r   argss     r   r   r          GW^4r   c                     [        SX-  S9  g )Nwarnr   r   r   s     r   r   r   #       FGN3r   c                     [        SX-  S9  g )Ninfor   r   r   s     r   r   r   '   r   r   c                     [        SX-  S9  g )Ndebugr   r   r   s     r   r   r   +   r   r   c                     [        SX-  S9  g )Nprint_statusr   r   r   s     r   r   r   /   s    NGN;r   c                 6    Ub  [        SU US9  g[        SU S9  g)a  Send runtime parameters back to the controller.

Args:
    params: ({str: object, ...}) Set of runtime parameters.  Must be
        json-encodable.
    appinfo: ({str: object, ...}) Contents of the app.yaml file to
        be produced by the runtime definition.  Required fields may be
        added to this by the framework, the only thing an application
        needs to provide is the "runtime" field and any additional data
        fields.
Nruntime_parameters)r   runtime_dataappinfo)r   r"   r   )paramsr#   s     r   send_runtime_paramsr%   3   s'     ,6"	$ 	,6Br   c                      [        SS9  [        [        R                  " [        R
                  R                  5       5      5      $ )zvRequest runtime parameters from the controller.

Returns:
  (object) The runtime parameters represented as an object.

get_config)r   )r   dict_to_objectr   loadsr   stdinreadline r   r   r'   r'   F   s-     L!$**SYY%7%7%9:;;r   c                      " S S[         5      nU" 5       nU R                  5        H1  u  p4[        U[        5      (       a  [	        U5      n[        X#U5        M3     U$ )zConverts a dictionary to a python object.

Converts key-values to attribute-values.

Args:
  json_dict: ({str: object, ...})

Returns:
  (object)
c                       \ rS rSrSrg)dict_to_object.<locals>.Object[   r,   N)__name__
__module____qualname____firstlineno____static_attributes__r,   r   r   Objectr/   [   s    r   r6   )object	iteritems
isinstancedictr(   setattr)	json_dictr6   objnamevals        r   r(   r(   P   sR     
(C((*	c4  s##3 + Jr   c                   $    \ rS rSrSrS rS rSrg)RuntimeDefinitionRoote   zDAbstraction that allows us to access files in the runtime definiton.c                     Xl         g Nroot)selfpaths     r   __init__RuntimeDefinitionRoot.__init__h   s    	r   c                     [        [        R                  R                  " U R                  /UQ76 5       nUR                  5       sS S S 5        $ ! , (       d  f       g = frD   )openosrH   joinrF   read)rG   r>   srcs      r   	read_fileRuntimeDefinitionRoot.read_filek   s7    "'',,tyy0401S88: 211s   A
ArE   N)r1   r2   r3   r4   __doc__rI   rQ   r5   r,   r   r   rA   rA   e   s    Nr   rA   c                     [        SXS9  g)zGenerate the file.

This writes the file to be generated back to the controller.

Args:
    name: (str) The UNIX-style relative path of the file.
    contents: (str) The complete file contents.
gen_file)r   filenamecontentsNr   )r>   rW   s     r   rU   rU   p   s     JAr   rD   )r   rM   r   r   r   r   r   r   r   r%   r'   r(   r7   rA   rU   r,   r   r   <module>rX      sP     	 
	5445<C&<*F 	Br   