Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: gslib/commands/mv.py

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gslib/commands/mb.py ('k') | gslib/commands/notification.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gslib/commands/mv.py
===================================================================
--- gslib/commands/mv.py (revision 33376)
+++ gslib/commands/mv.py (working copy)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
# Copyright 2011 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,30 +12,21 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Implementation of Unix-like mv command for cloud storage providers."""
+from __future__ import absolute_import
+
from gslib.command import Command
-from gslib.command import COMMAND_NAME
-from gslib.command import COMMAND_NAME_ALIASES
-from gslib.command import FILE_URIS_OK
-from gslib.command import MAX_ARGS
-from gslib.command import MIN_ARGS
-from gslib.command import PROVIDER_URIS_OK
-from gslib.command import SUPPORTED_SUB_ARGS
-from gslib.command import URIS_START_ARG
from gslib.commands.cp import CP_SUB_ARGS
+from gslib.cs_api_map import ApiSelector
from gslib.exception import CommandException
-from gslib.help_provider import HELP_NAME
-from gslib.help_provider import HELP_NAME_ALIASES
-from gslib.help_provider import HELP_ONE_LINE_SUMMARY
-from gslib.help_provider import HELP_TEXT
-from gslib.help_provider import HelpType
-from gslib.help_provider import HELP_TYPE
+from gslib.storage_url import StorageUrlFromString
from gslib.util import NO_MAX
-_detailed_help_text = ("""
+_DETAILED_HELP_TEXT = ("""
<B>SYNOPSIS</B>
- gsutil mv [-p] src_uri dst_uri
- gsutil mv [-p] uri... dst_uri
+ gsutil mv [-p] src_url dst_url
+ gsutil mv [-p] url... dst_url
<B>DESCRIPTION</B>
@@ -64,7 +56,7 @@
should use the -p option (see OPTIONS).
Note that when using mv to rename bucket subdirectories you cannot specify
- the source URI using wildcards. You need to spell out the complete name:
+ the source URL using wildcards. You need to spell out the complete name:
gsutil mv gs://my_bucket/olddir gs://my_bucket/newdir
@@ -91,48 +83,42 @@
class MvCommand(Command):
"""Implementation of gsutil mv command.
+
Note that there is no atomic rename operation - this command is simply
a shorthand for 'cp' followed by 'rm'.
"""
- # Command specification (processed by parent class).
- command_spec = {
- # Name of command.
- COMMAND_NAME : 'mv',
- # List of command name aliases.
- COMMAND_NAME_ALIASES : ['move', 'ren', 'rename'],
- # Min number of args required by this command.
- MIN_ARGS : 2,
- # Max number of args required by this command, or NO_MAX.
- MAX_ARGS : NO_MAX,
- # Getopt-style string specifying acceptable sub args.
- SUPPORTED_SUB_ARGS : CP_SUB_ARGS, # Flags for mv are passed through to cp.
- # True if file URIs acceptable for this command.
- FILE_URIS_OK : True,
- # True if provider-only URIs acceptable for this command.
- PROVIDER_URIS_OK : False,
- # Index in args of first URI arg.
- URIS_START_ARG : 0,
- }
- help_spec = {
- # Name of command or auxiliary help info for which this help applies.
- HELP_NAME : 'mv',
- # List of help name aliases.
- HELP_NAME_ALIASES : ['move', 'rename'],
- # Type of help:
- HELP_TYPE : HelpType.COMMAND_HELP,
- # One line summary of this help.
- HELP_ONE_LINE_SUMMARY : 'Move/rename objects and/or subdirectories',
- # The full help text.
- HELP_TEXT : _detailed_help_text,
- }
+ # Command specification. See base class for documentation.
+ command_spec = Command.CreateCommandSpec(
+ 'mv',
+ command_name_aliases=['move', 'ren', 'rename'],
+ min_args=2,
+ max_args=NO_MAX,
+ # Flags for mv are passed through to cp.
+ supported_sub_args=CP_SUB_ARGS,
+ file_url_ok=True,
+ provider_url_ok=False,
+ urls_start_arg=0,
+ gs_api_support=[ApiSelector.XML, ApiSelector.JSON],
+ gs_default_api=ApiSelector.JSON,
+ )
+ # Help specification. See help_provider.py for documentation.
+ help_spec = Command.HelpSpec(
+ help_name='mv',
+ help_name_aliases=['move', 'rename'],
+ help_type='command_help',
+ help_one_line_summary='Move/rename objects and/or subdirectories',
+ help_text=_DETAILED_HELP_TEXT,
+ subcommand_help_text={},
+ )
- # Command entry point.
def RunCommand(self):
- # Check each source arg up, refusing to delete a bucket src URI (force users
+ """Command entry point for the mv command."""
+ # Check each source arg up, refusing to delete a bucket src URL (force users
# to explicitly do that as a separate operation).
for arg_to_check in self.args[0:-1]:
- if self.suri_builder.StorageUri(arg_to_check).names_bucket():
+ url = StorageUrlFromString(arg_to_check)
+ if url.IsCloudUrl() and (url.IsBucket() or url.IsProvider()):
raise CommandException('You cannot move a source bucket using the mv '
'command. If you meant to move\nall objects in '
'the bucket, you can use a command like:\n'
@@ -144,7 +130,7 @@
# use-only) cp -M option, which causes each original object to be deleted
# after successfully copying to its destination, and also causes naming
# behavior consistent with Unix mv naming behavior (see comments in
- # _ConstructDstUri in cp.py).
+ # ConstructDstUrl).
unparsed_args = ['-M']
if self.recursion_requested:
unparsed_args.append('-R')
« no previous file with comments | « gslib/commands/mb.py ('k') | gslib/commands/notification.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698