
                         l   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r\R                  " SS5      rS r\R$                  " \R&                  R(                  \R&                  R*                  \R&                  R,                  5       " S S\R.                  5      5       rg
)zcloud-shell scp command.    )absolute_import)division)unicode_literals)arg_parsers)base)util)ssh)logNz^(cloudshell|localhost):.*$z)must start with cloudshell: or localhost:c                 ^   U R                  S5      (       aD  [        R                  R                  U R	                  S[
        R                  " U5      S5      5      $ U R                  S5      (       a0  [        R                  R                  U R	                  SSS5      5      $ [        SU -   5      e)Nzcloudshell:
cloudshell   z
localhost: zinvalid path: )
startswithr	   FileReferenceFromPathreplacesix	text_type	Exception)pathremotes     lib/surface/cloud_shell/scp.pyToFileReferencer       s    	__]##%%\3==#8!<> >|$$%%dll<Q&GHH
$t+
,,    c                   8    \ rS rSrSrSSS.r\S 5       rS rSr	g	)
Scp*   z7Copies files between Cloud Shell and the local machine.z        *{command}* copies files between your Cloud Shell instance and your
        local machine using the scp command.
        a;          To denote a file in Cloud Shell, prefix the file name with the string
        "cloudshell:" (e.g. _cloudshell:_~/_FILE_). To denote a local file,
        prefix the file name with the string "localhost:" (e.g.
        _localhost:_~/_FILE_). For example, to copy a remote directory to your
        local machine, run:

            $ {command} cloudshell:~/REMOTE-DIR localhost:~/LOCAL-DIR

        In the above example, *_~/REMOTE-DIR_* from your Cloud Shell instance is
        copied into the ~/_LOCAL-DIR_ directory.

        Conversely, files from your local computer can be copied into Cloud
        Shell:

            $ {command} localhost:~/LOCAL-FILE-1 localhost:~/LOCAL-FILE-2 cloudshell:~/REMOTE-DIR

        Under the covers, *scp(1)* or pscp (on Windows) is used to facilitate
        the transfer.
        )DESCRIPTIONEXAMPLESc                     [         R                  " U 5        U R                  SS[        SSS9  U R                  SS[        SS	9  U R                  S
SSS9  U R                  SSSS9  U R                  SSSS9  g )NsourceszSpecifies the files to copy.z(cloudshell|localhost):SRC+)helptypemetavarnargsdestinationz-Specifies a destination for the source files.z(cloudshell|localhost):DEST)r#   r$   r%   z	--dry-runzs        If provided, prints the command that would be run to standard out
        instead of executing it.
        
store_true)r#   actionz	--recursezUpload directories recursively.z
--scp-flagz8Extra flag to be sent to scp. This flag may be repeated.append)r   ParseCommonArgsadd_argument	FILE_TYPE)parsers    r   ArgsScp.ArgsM   s     
+,   <-	  /
     .   G  r   c                 n   [         R                  " U5      n[        R                  " UR                  UR
                  S9n[        R                  " UR                   Vs/ s H  n[        XC5      PM     sn[        UR                  U5      UR                  S[        UR                  5      UR                  UR                  SS0S9nUR                  (       a?  [         R"                  " SR%                  UR'                  UR(                  5      5      5        g UR+                  UR(                  5        g s  snf )N)hostuserFStrictHostKeyCheckingno)r!   r'   	recursivecompressportidentity_fileextra_flagsoptions )r   PrepareEnvironmentr	   Remoter2   r3   
SCPCommandr!   r   r'   recursestrr8   keyscp_flagdry_runr
   PrintjoinBuildssh_envRun)selfargsconnection_infor   srccommands         r   rI   Scp.Runk   s    --d3OZZ_118L8LMFnn9=F#-F#D$4$4f=,,%%&%))MM($/	G ||	ii'>'>?@Akk/))* Gs   D2 N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr/   rI   __static_attributes__rP   r   r   r   r   *   s2     @
-<  :+r   r   )rU   
__future__r   r   r   googlecloudsdk.callioper   r   &googlecloudsdk.command_lib.cloud_shellr   #googlecloudsdk.command_lib.util.sshr	   googlecloudsdk.corer
   r   RegexpValidatorr-   r   ReleaseTracksReleaseTrackGABETAALPHACommandr   rP   r   r   <module>re      s     &  ' / ( 7 3 # 
''"$OQ	- D%%(($*;*;*@*@%%++-P+$,, P+-P+r   