
                             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  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S\-   S-   r0 \ESSS.Er " S S\5      rg)zCImplementation of Unix-like mv command for cloud storage providers.    )absolute_import)print_function)division)unicode_literals)Command)CommandArgument)CP_AND_MV_SHIM_FLAG_MAP)CP_SUB_ARGS)'ShimTranslatePredefinedAclSubOptForCopy)ApiSelector)CommandException)StorageUrlFromString)NO_MAX)GcloudStorageMapzb
  gsutil mv [-p] src_url dst_url
  gsutil mv [-p] src_url... dst_url
  gsutil mv [-p] -I dst_url
z
<B>SYNOPSIS</B>
a  


<B>DESCRIPTION</B>
  The ``gsutil mv`` command allows you to move data between your local file
  system and the cloud, move data within the cloud, and move data between
  cloud storage providers. For example, to move all objects from a
  bucket to a local directory you could use:

    gsutil mv gs://my_bucket/* dir

  Similarly, to move all objects from a local directory to a bucket you could
  use:

    gsutil mv ./dir gs://my_bucket


<B>RENAMING GROUPS OF OBJECTS</B>
  You can use the ``gsutil mv`` command to rename all objects with a given
  prefix to have a new prefix. For example, the following command renames all
  objects under gs://my_bucket/oldprefix to be under gs://my_bucket/newprefix,
  otherwise preserving the naming structure:

    gsutil mv gs://my_bucket/oldprefix gs://my_bucket/newprefix

  If you do a rename as specified above and you want to preserve ACLs, you
  should use the ``-p`` option (see OPTIONS).

  If you have a large number of files to move you might want to use the
  ``gsutil -m`` option, to perform a multi-threaded/multi-processing move:

    gsutil -m mv gs://my_bucket/oldprefix gs://my_bucket/newprefix


<B>NON-ATOMIC OPERATION</B>
  Unlike the case with many file systems, the gsutil mv command does not
  perform a single atomic operation. Rather, it performs a copy from source
  to destination followed by removing the source for each object.

  A consequence of this is that, in addition to normal network and operation
  charges, if you move a Nearline Storage, Coldline Storage, or Archive Storage
  object, deletion and data retrieval charges apply. See the `documentation
  <https://cloud.google.com/storage/pricing>`_ for pricing details.


<B>OPTIONS</B>
  All options that are available for the gsutil cp command are also available
  for the gsutil mv command (except for the -R flag, which is implied by the
  ``gsutil mv`` command). Please see the `Options section for cp
  <https://cloud.google.com/storage/docs/gsutil/commands/cp#options>`_
  for more information.

N)z-r-Rc                      ^  \ rS rSrSr\R                  " S/ SQ\S\\	SSS\
R                  \
R                  /\
R                  \R                  " 5       /S	9r\R                   " SS
S/SS\0 S9rU 4S jrS rSrU =r$ )	MvCommandc   zImplementation of gsutil mv command.

Note that there is no atomic rename operation - this command is simply
a shorthand for 'cp' followed by 'rm'.
mv)moverenrename   TFr   )command_name_aliasesusage_synopsismin_argsmax_argssupported_sub_argsfile_url_okprovider_url_okurls_start_arggs_api_supportgs_default_apiargparse_argumentsr   r   command_helpzMove/rename objects)	help_namehelp_name_aliases	help_typehelp_one_line_summary	help_textsubcommand_help_textc                 l   > [        U R                  5        [        SS/[        S9n[        TU ]  U5      $ )Nstorager   )gcloud_commandflag_map)r   sub_optsr   MV_SHIM_FLAG_MAPsuperget_gcloud_storage_args)selfgcloud_storage_map	__class__s     $platform/gsutil/gslib/commands/mv.pyr3   !MvCommand.get_gcloud_storage_args   s8    +DMM:)!4(! 7*+=>>    c           
      *   U R                   SS  Ho  n[        U5      nUR                  5       (       d  M%  UR                  5       (       d  UR	                  5       (       d  MQ  [        SU< SU R                   S   < 35      e   S/nU R                  (       a  UR                  S5        UR                  U R                  5        U R                  R                  SUU R                  U R                  U R                  U R                  U R                   S9  g)	z'Command entry point for the mv command.r   zYou cannot move a source bucket using the mv command. If you meant to move
all objects in the bucket, you can use a command like:
	gsutil mv z/* z-Mr   cp)argsheadersdebugtrace_tokenuser_projectparallel_operations)r=   r   
IsCloudUrlIsBucket
IsProviderr   recursion_requestedappendextendunparsed_argscommand_runnerRunNamedCommandr>   r?   r@   rA   rB   )r4   arg_to_checkurlrI   s       r7   
RunCommandMvCommand.RunCommand   s     		!B .c			s||~~1A1A !-diim	 = > 	> ( FM4 ++,''jj$$&& 44 ( 6 r9    )__name__
__module____qualname____firstlineno____doc__r   CreateCommandSpec	_SYNOPSISr   r
   r   XMLJSONr   %MakeZeroOrMoreCloudOrFileURLsArgumentcommand_specHelpSpec_DETAILED_HELP_TEXT	help_specr3   rN   __static_attributes____classcell__)r6   s   @r7   r   r   c   s     **
4$!oo{'7'78 %%

?
?
A,$ *1#)?   r9   r   )rU   
__future__r   r   r   r   gslib.commandr   gslib.command_argumentr   gslib.commands.cpr	   r
   r   gslib.cs_api_mapr   gslib.exceptionr   gslib.storage_urlr   gslib.utils.constantsr   gslib.utils.shim_utilr   rW   r]   r1   r   rP   r9   r7   <module>rj      s{    J & %  ' ! 2 5 ) E ( , 2 ( 2	46 r G-FTF K Kr9   