
    X                        S r SSKJr  SSKJr  SSKJ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R!                  \R"                  SS/5      rSR!                  \R"                  SS/5      rSR!                  \R"                  SSSS/5      rSR!                  \R"                  SSSSSSSSSS/5      rSR!                  \R"                  SS/5      r\R.                  " \R0                  \R2                  15      \\R.                  " \R4                  \R2                  15      \\R.                  " \R6                  \R2                  15      \\R.                  " \R8                  \R2                  15      \\R.                  " \R:                  \R2                  15      \0r " S  S!\R>                  5      r S" r! S$S# jr"g)%zUtility methods for iterating over source files for deployment.

Based on the runtime and environment, this can entail generating a new
.gcloudignore, using an existing .gcloudignore, or using existing skip_files.
    )absolute_import)division)unicode_literalsN)env)runtime_registry)util)
exceptions)gcloudignore
z# Node.js dependencies:znode_modules/z# PHP Composer dependencies:z/vendor/z# Python pycache:z__pycache__/z# Ignored by the build systemz
/setup.cfgz## Binaries for programs and pluginsz*.exez*.exe~z*.dllz*.soz*.dylibz&# Test binary, build with `go test -c`z*.testzE# Output of the go coverage tool, specifically when used with LiteIDEz*.outz## Target directory for maven buildsztarget/c                       \ rS rSrSrg)SkipFilesErrorZ    N)__name__
__module____qualname____firstlineno____static_attributes__r       7lib/googlecloudsdk/command_lib/app/source_files_util.pyr   r   Z   s    r   r   c                  4    [         R                  " [        SS9$ )NF)default)r   Registry_GCLOUDIGNORE_REGISTRYr   r   r   _GetGcloudignoreRegistryr   ^   s    		"	"#95	IIr   c           	         [        5       nUR                  X45      nU(       aM  U(       a  [        SR                  U5      5      e[        R
                  " UUSS USS9n	U	R                  U SS9n
GONU(       a  [        R                  R                  [        R                  R                  XV5      5      (       aD  U(       a  [        SR                  U5      5      e[        R
                  " XVS9R                  U SS9n
O[        R                  " S	R                  U5      5      e[        R                  R                  [        R                  R                  U[        R                  5      5      (       a7  U(       a  [        S
5      e[        R
                  " U5      R                  U SS9n
O[        R                  " X5      n
[!        U
5      $ )aI  Returns an iterator for accessing all source files to be uploaded.

This method uses several implementations based on the provided runtime and
env. The rules are as follows, in decreasing priority:
1) For some runtimes/envs (i.e. those defined in _GCLOUDIGNORE_REGISTRY), we
   completely ignore skip_files and generate a runtime-specific .gcloudignore
   if one is not present, or use the existing .gcloudignore.
2) For all other runtimes/envs, we:
  2a) If ignore_file is not none, use custom ignore_file to skip files. If the
      specified file does not exist, raise error. We also raise an error if
      the user has both ignore file and explicit skip_files defined.
  2b) If user does not specify ignore_file, check for an existing
      .gcloudignore and use that if one exists. We also raise an error if
      the user has both a .gcloudignore file and explicit skip_files defined.
  2c) If there is no .gcloudignore, we use the provided skip_files.

Args:
  upload_dir: str, path to upload directory, the files to be uploaded.
  skip_files_regex: str, skip_files to use if necessary - see above rules for
    when this could happen. This can be either the user's explicit skip_files
    as defined in their app.yaml or the default skip_files we implicitly
    provide if they didn't define any.
  has_explicit_skip_files: bool, indicating whether skip_files_regex was
    explicitly defined by the user
  runtime: str, runtime as defined in app.yaml
  environment: env.Environment enum
  source_dir: str, path to original source directory, for writing generated
    files. May be the same as upload_dir.
  ignore_file: custom ignore_file name.
            Override .gcloudignore file to customize files to be skipped.

Raises:
  SkipFilesError: if you are using a runtime that no longer supports
    skip_files (such as those defined in _GCLOUDIGNORE_REGISTRY), or if using
    a runtime that still supports skip_files, but both skip_files and
    a. gcloudignore file are present.
  FileNotFoundError: if the custom ignore-file does not exist.

Returns:
  A list of path names of source files to be uploaded.
zskip_files cannot be used with the [{}] runtime. Ignore patterns are instead expressed in a .gcloudignore file. For information on the format and syntax of .gcloudignore files, see https://cloud.google.com/sdk/gcloud/reference/topic/gcloudignore.Tc                     g)NTr   )
unused_dirs    r   <lambda> GetSourceFiles.<locals>.<lambda>   s    Dr   F)default_ignore_filewrite_on_disk gcloud_ignore_creation_predicateignore_fileinclude_gitignore)include_dirszCannot have both an ignore file {0} and skip_files defined in the same application. We recommend you translate your skip_files ignore patterns to your {0} file. )r$   z4File {0} referenced by --ignore-file does not exist.a  Cannot have both a .gcloudignore file and skip_files defined in the same application. We recommend you translate your skip_files ignore patterns to your .gcloudignore file. See https://cloud.google.com/sdk/gcloud/reference/topic/gcloudignore for more information about gcloudignore.)r   Getr   formatr
   GetFileChooserForDirGetIncludedFilesospathexistsjoinr	   FileNotFoundErrorIGNORE_FILE_NAMEr   FileIteratorlist)
upload_dirskip_files_regexhas_explicit_skip_filesruntimeenvironment
source_dirr$   gcloudignore_registryregistry_entryfile_chooserits              r   GetSourceFilesr=   b   s   V 34(,,WB.N
 6'?   44*)@!L 
	&	&z	&	FB	ww~~bggll:;<<	 1171DF 	F ,,ZQJU; 	 (( *;;A6+;NP P	ww~~bggll:|/L/LMNN56 6 
	*	*:	6	G	G 
H 
(B 
		:	8B	b/r   )N)#__doc__
__future__r   r   r   r+   googlecloudsdk.api_lib.appr   r   r   googlecloudsdk.command_lib.appr	   googlecloudsdk.command_lib.utilr
   googlecloudsdk.corecore_exceptionsr.   DEFAULT_IGNORE_FILE_NODE_GCLOUDIGNORE_PHP_GCLOUDIGNORE_PYTHON_GCLOUDIGNORE_GO_GCLOUDIGNORE_JAVA_GCLOUDIGNORERegistryEntryNODE_TI_RUNTIME_EXPRSTANDARDPHP_TI_RUNTIME_EXPRPYTHON_TI_RUNTIME_EXPRGO_TI_RUNTIME_EXPRJAVA_TI_RUNTIME_EXPRr   Errorr   r   r=   r   r   r   <module>rS      s   '  ' 	 * 7 + 5 8 = YY$$    II$$"   yy$$#"   99$$)
,K   YY$$)    ""  3<<.23E""#,,12C""""S\\N45I""01A""  3<<.23E _** J
 BFWr   