
                            S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKrSSK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rSRA                  \RB                  S9r"S r#S r$\RJ                  " S\"S9\RL                  " \RN                  RP                  5       " S S\RR                  5      5       5       r*S r+SSS.r,\,\*l-        g)zThe gen-config command.    )absolute_import)division)unicode_literalsN)ext_runtime)yaml_parsing)fingerprinter)appinfo)base)deployables)
exceptions)output_helpers)log)
console_io)files)yamlzThis command is deprecated and will soon be removed.

{fingerprinting}

To create a custom runtime, please follow the instructions at
https://cloud.google.com/appengine/docs/flexible/custom-runtimes/
)fingerprintingc                 B   U R                  SSS[        R                  " 5       S9  U R                  SSSS9  [        R                  " 5        Vs/ s H  oS	;  d  M
  UPM     nnU R                  S
SSSR                  U5      -   S-   S9  U R                  SSSSS9  gs  snf )z*Add arguments for `gcloud app gen-config`.
source_dir?z$The source directory to fingerprint.)nargshelpdefaultz--configNzThe yaml file defining the service configuration.  This is normally one of the generated files, but when generating a custom runtime there can be an app.yaml containing parameters.)r   r   )vmcustomz	--runtimezkGenerate config files for a given runtime. Can be used in conjunction with --custom. Allowed runtimes are: z, .z--custom
store_trueFzIf true, generate config files for a custom runtime.  This will produce a Dockerfile, a .dockerignore file and an app.yaml (possibly other files as well, depending on the runtime).)actionr   r   )add_argumentr   GetCWDr	   GetAllRuntimesjoin)parserrrt_lists      lib/surface/app/gen_config.py_Argsr&   6   s    1lln	  
 	M  O  ..0N01=M4MQ0'N@IIg!$%  ' 	H	  J Os   	BBc           	         U R                   (       a  U R                   nOP[        R                  R                  U R                  S5      n[        R                  R                  U5      (       d  SnU(       a-   [        R                  R                  U5      nUR                  nOSn[        R                  " U R                  [        R                   " X0R"                  U R$                  S9U5        U(       a  U R"                  (       a  UR'                  5       S:w  a  [(        R*                  " S[,        R.                  R1                  U5      SS9nU(       a;  [3        US5        [        R4                  R7                  S	R1                  U5      5        g[        R4                  R7                  S
R1                  U5      5        gggg! [         a!  n[        R                  " SX5         SnAgSnAff = f)z(Run the `gcloud app gen-config` command.zapp.yamlNzUnable to open %s: %s)r	   r   runtimer   Fz Would you like to update it now?)r   messageprompt_stringz[{0}] has been updated.zEPlease update [{0}] manually by changing the runtime field to custom.)configospathr!   r   existsr   ServiceYamlInfoFromFileparsedIOErrorr   errorr   GenerateConfigsr   Paramsr   r(   GetEffectiveRuntimer   PromptContinuer   RUNTIME_MISMATCH_MSGformat_AlterRuntimestatusPrint)argsconfig_filenamemyir+   exalters         r%   _RunrB   T   si   	[[kkO ggll4??J?O77>>/**o ((11/Bczzf
 F
oo!%/	  : : < H%%33::?K8:E OX.	jj077HI	jj **0&*AC !IV  	ii'=s   7+G 
G,G''G,F)
is_removedwarningc                   .    \ rS rSrSr\S 5       rS rSrg)	GenConfig   z<Generate missing configuration files for a source directory.c                     [        U 5        g )N)r&   )r"   s    r%   ArgsGenConfig.Args   s	    	&M    c                 p    [         R                  (       a  [        R                  " S5      e[	        U5        g )Nz&This command does not support python3.)sixPY3r   NotSupportedPy3ExceptionrB   )selfr=   s     r%   RunGenConfig.Run   s&    
ww//
24 4JrK    N)	__name__
__module____qualname____firstlineno____doc__staticmethodrI   rQ   __static_attributes__rS   rK   r%   rF   rF      s     E rK   rF   c                     [         R                  " SS9 nUR                  nS S S 5        [        R                  R                  SR                  U W5      5        [        R                  " X5        [        R                  " U 5       nUR                  n[        R                  " U[        R                  5      nS S S 5        UWS'   [        R                   " 5       n[        R"                  " UW5      n[        R$                  " Xh[        R&                  S9  [        R(                  " U 5       nUR+                  S5        UR-                  UR/                  5       5        S S S 5        g ! , (       d  f       GNH= f! , (       d  f       N= f! , (       d  f       g = f! [0         a  n	[2        R4                  " U	5      eS n	A	ff = f)Nz	app.yaml.)prefixz7Copying original config [{0}] to backup location [{1}].r(   )Dumperr   )tempfileNamedTemporaryFilenamer   r;   r<   r9   shutilcopyfiler   
FileReaderencodingr   loadRoundTripLoaderioBytesIOTextIOWrapperdumpRoundTripDumperBinaryFileWriterseekwritegetvalue	Exceptionr   AlterConfigFileError)
r>   r(   fbackup_fname	yaml_filerd   r+   raw_buftmp_yaml_bufes
             r%   r:   r:      sC   0		$	$K	8AVVl 
9JJAHH\	+, OOO2			/	*i##hyyD$8$89f 
+  F9jjlG##GX6LIIf4+?+?@				0Ioog&&() 
1	0# 
9	8 
+	* 
1	0 
 0

,
,Q
//0se   F E$A#F 2E68A2F *1FF $
E3.F 6
F F 
FF F 
F="F88F=z    This command generates all relevant config files (app.yaml, Dockerfile and a
    build Dockerfile) for your application in the current directory or emits an
    error message if the source directory contents are not recognized.
    z    To generate configs for the current directory:

      $ {command}

    To generate configs for ~/my_app:

      $ {command} ~/my_app
    )DESCRIPTIONEXAMPLES).rX   
__future__r   r   r   rg   r,   ra   r^   gae_ext_runtimer   googlecloudsdk.api_lib.appr   #googlecloudsdk.api_lib.app.runtimesr   googlecloudsdk.appengine.apir	   googlecloudsdk.callioper
   googlecloudsdk.command_lib.appr   r   r   googlecloudsdk.corer   googlecloudsdk.core.consoler   googlecloudsdk.core.utilr   ruamelr   rM   r9   FINGERPRINTING_WARNING_DEPRECATION_MSGr&   rB   	DeprecateReleaseTracksReleaseTrackBETACommandrF   r:   _DETAILED_HELPdetailed_helprS   rK   r%   <module>r      s      '  ' 	 	   ' 3 = 0 ( 6 5 9 # 2 *  
 F+<<F= J<)CX 5*:;D%%**+  , <06
" )	 rK   