
                          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K	J
r
  SSK	Jr  SS	KJr  SS
KJr  \R                  " SSS/5      \R                  " SSSS/5      \R                  " SSSS/5      \R                  " SSSS/5      \R                  " SS/ SQ5      \\R                  " SSSS/5      \R                  " SSSS/5      /r " S S\R"                  5      r " S S\R"                  5      r " S S\R"                  5      r " S  S!\R"                  5      rS'S# jrS(S$ jrS(S% jrS(S& jrg"))z4Package containing fingerprinting for all runtimes.
    )absolute_import)division)unicode_literals)ext_runtime)ext_runtime_adapter)python)python_compat)
exceptions)logcustomCustomgoGorubyRubynodejszNode.jsjavaJava)r   java7r   r   PythonphpPHPc                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )UnidentifiedDirectoryError9   z;Raised when GenerateConfigs() can't identify the directory.c                 V   > [         [        U ]  SR                  U5      5        Xl        g)zJConstructor.

Args:
  path: (basestring) Directory we failed to identify.
z"Unrecognized directory type: [{0}]N)superr   __init__formatpath)selfr    	__class__s     8lib/googlecloudsdk/api_lib/app/runtimes/fingerprinter.pyr   #UnidentifiedDirectoryError.__init__<   s(     

$d4,33D9;I    )r    __name__
__module____qualname____firstlineno____doc__r   __static_attributes____classcell__r"   s   @r#   r   r   9   s    C r%   r   c                       \ rS rSrSrSrg)ExtRuntimeErrorG   z/ext_runtime.Error errors are converted to this. Nr'   r(   r)   r*   r+   r,   r2   r%   r#   r0   r0   G   s    7r%   r0   c                       \ rS rSrSrSrg)ConflictingConfigErrorK   zCProperty in app.yaml conflicts with params passed to fingerprinter.r2   Nr3   r2   r%   r#   r5   r5   K   s    Kr%   r5   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )AlterConfigFileErrorO   zCError when attempting to update an existing config file (app.yaml).c                 J   > [         [        U ]  SR                  U5      5        g )NzWCould not alter app.yaml due to an internal error:
{0}
Please update app.yaml manually.)r   r8   r   r   )r!   inner_exceptionr"   s     r#   r   AlterConfigFileError.__init__R   s#    	
.	++16/+BDr%   r2   r&   r.   s   @r#   r8   r8   O   s    KD Dr%   r8   Nc                 H   U(       d  [         R                  " 5       nUR                  (       a  UR                  nO.UR                  (       a  UR                  R	                  5       nOSnUS:X  a  SUl        [         Hr  nU(       aK  UR                  (       a:  X#R                  ;  a+  [        R                  " SUR                  < SU< S35        MU   UR                  X5      nU(       d  Mp  Us  $    g! [         R                   a  n[        UR                  5      eSnAff = f)a  Try to identify the given directory.

As a side-effect, if there is a config file in 'params' with a runtime of
'custom', this sets params.custom to True.

Args:
  path: (basestring) Root directory to identify.
  params: (ext_runtime.Params or None) Parameters passed through to the
    fingerprinters.  Uses defaults if not provided.

Returns:
  (ext_runtime.Configurator or None) Returns a module if we've identified
  it, None if not.
Nr   TzNot checking for [z] because runtime is [])r   ParamsruntimeappinfoGetEffectiveRuntimer   RUNTIMESALLOWED_RUNTIME_NAMESr   infoNAMEFingerprintErrorr0   message)r    paramsspecified_runtimer@   configuratorexs         r#   IdentifyDirectoryrN   X   s     
!F ^^~~::<("FMg 	g;;!>!>>	hh/1 2(((6l |   
	  (BJJ''(s   C33D!DD!c                    U(       d  [         R                  " 5       nUR                  nU(       a  UR                  (       d  UR                  (       d  [        S5      eUR                  5       (       d  [        S5      eUR                  5       S:w  a^  UR                  bQ  UR                  UR                  5       :w  a3  [        SR                  X#R                  5       UR                  5      5      e[        X5      nU(       d  [        U 5      eU$ )a  Helper function for generating configs.

Args:
  path: (basestring) Root directory to identify.
  params: (ext_runtime.Params or None) Parameters passed through to the
    fingerprinters.  Uses defaults if not provided.
  config_filename: (str or None) Filename of the config file (app.yaml).

Raises:
  UnidentifiedDirectoryError: No runtime module matched the directory.
  ConflictingConfigError: Current app.yaml conflicts with other params.

Returns:
  ext_runtime.Configurator, the configurator for the path
zConfiguration file already exists. This command generates an app.yaml configured to run an application on Google App Engine. To create the configuration files needed to run this application with docker, try `gcloud preview app gen-config --custom`.zgen-config is only supported for App Engine Flexible.  Please use "vm: true" in your app.yaml if you would like to use App Engine Flexible to run your application.r   z@[{0}] contains "runtime: {1}" which conficts with --runtime={2}.)r   r?   rA   deployr   r5   IsVmrB   r@   r   rN   r   )r    rJ   config_filenameconfigmodules        r#   
_GetModulerU      s      
!F>>&FMM=="  ;;=="./ /
 	""$0V^^5ONNf88::"!6/3M3M3O"(..23 3
 T*&	
$T
**	-r%   c                     [        XUS9n UR                  5       $ ! [        R                   a  n[	        UR
                  5      eSnAff = f)a9  Identify runtime and generate config files for a directory.

If a runtime can be identified for the given directory, calls the runtime's
GenerateConfigs method, which writes configs to the directory.

Args:
  path: (basestring) Root directory to identify.
  params: (ext_runtime.Params or None) Parameters passed through to the
    fingerprinters.  Uses defaults if not provided.
  config_filename: (str or None) Filename of the config file (app.yaml).

Raises:
  ExtRuntimeError: if there was an error generating configs

Returns:
  (bool): True if files were written
rJ   rR   N)rU   GenerateConfigsr   rH   r0   rI   r    rJ   rR   rT   rM   s        r#   rX   rX      sI    $ d?K&&!!##			 &
"**
%%&    A
AA
c                     [        XUS9n UR                  5       $ ! [        R                   a  n[	        UR
                  5      eSnAff = f)a`  Identify runtime and generate contents of config files for a directory.

If a runtime can be identified for the given directory, calls the runtime's
GenerateConfigData method, which generates the contents of config files.

Args:
  path: (basestring) Root directory to identify.
  params: (ext_runtime.Params or None) Parameters passed through to the
    fingerprinters.  Uses defaults if not provided.
  config_filename: (str or None) Filename of the config file (app.yaml).

Raises:
  ExtRuntimeError: if there was an error generating configs

Returns:
  [ext_runtime.GeneratedFile] generated config files.
rW   N)rU   GenerateConfigDatar   rH   r0   rI   rY   s        r#   r\   r\      sI    $ d?K&&$$&&			 &
"**
%%&rZ   )N)NN)r+   
__future__r   r   r   gae_ext_runtimer   googlecloudsdk.api_lib.appr   #googlecloudsdk.api_lib.app.runtimesr   r	   googlecloudsdk.corer
   r   CoreRuntimeLoaderrC   rH   r   r0   r5   r8   rN   rU   rX   r\   r2   r%   r#   <module>rc      sA    '  ' ' : 6 = * # ))(H+3*6 ))$tX6FG))&&68:LM))(I+3X*>@))&&*EG ))(H+3X*>@))%8IJ-4!1!1 8j&& 8LZ-- LD:++ D-`/d&4&r%   