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

Side by Side Diff: third_party/gsutil/gslib/addlhelp/subdirs.py

Issue 10199002: Upgrade gsutil to 3.4 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments Created 8 years, 8 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright 2012 Google Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 from gslib.help_provider import HELP_NAME
16 from gslib.help_provider import HELP_NAME_ALIASES
17 from gslib.help_provider import HELP_ONE_LINE_SUMMARY
18 from gslib.help_provider import HelpProvider
19 from gslib.help_provider import HELP_TEXT
20 from gslib.help_provider import HelpType
21 from gslib.help_provider import HELP_TYPE
22
23 _detailed_help_text = ("""
24 <B>OVERVIEW</B>
25 This section provides details about how subdirectories work in gsutil.
26 Most users probably don't need to know these details, and can simply use
27 the commands (like cp -R) that work with subdirectories. We provide this
28 additional documentation to help users understand how gsutil handles
29 subdirectories differently than most GUI / web-based tools (e.g., why
30 those other tools create "$folder$" objects), and also to explain cost and
31 performance implications of the gsutil approach, for those interested in
32 such details.
33
34 gsutil provides the illusion of a hierarchical file tree atop the "flat"
35 name space supported by the Google Cloud Storage service. To the service,
36 the object gs://bucket/abc/def/ghi.txt is just an object that happens to have
37 "/" characters in its name. There are no "abc" or "abc/def" directories;
38 just a single object with the given name.
39
40 gsutil achieves the hierarchical file tree illusion by performing a bucket
41 listing at the time you run cp, mv, and ls commands, to determine if the
42 target of the operation is a prefix match to the specified string. For
43 example, if you run the command:
44
45 gsutil cp file gs://bucket/abc
46
47 gsutil will first make a bucket listing request for the named bucket, using
48 delimiter="/" and prefix="abc". It will then examine the bucket listing
49 results and determine whether there are objects in the bucket whose path
50 starts with gs://bucket/abc/, to determine whether to treat the target as
51 an object name or a directory name. In turn this impacts the name of the
52 object you create: If the above check indicates there is an "abc" directory
53 you will end up with the object gs://bucket/abc/file; otherwise you will
54 end up with the object gs://bucket/abc. (See "HOW NAMES ARE CONSTRUCTED"
55 under "gsutil help cp" for more details.)
56
57 This stands in contrast to the way many tools work, by creating objects to
58 mark the existence of folders (such as "$folder$"). gsutil does not require
59 such marker objects to implement naming behavior consistent with UNIX commands
60 (so, can work with subdirectories created by a tool that doesn't use the
61 "$folder$" convention).
62
63 A downside of the gsutil approach is it requires an extra bucket listing
64 when performing cp and mv. However those listings are relatively
65 inexpensive, because they use delimiter and prefix parameters to limit result
66 data. Moreover, gsutil makes only one bucket listing request per cp/mv/ls
67 command, and thus amortizes the bucket listing cost across all transferred
68 objects (e.g., when performing a recursive copy of a directory to the cloud).
69 """)
70
71
72
73 class CommandOptions(HelpProvider):
74 """Additional help about subdirectory handling in gsutil."""
75
76 help_spec = {
77 # Name of command or auxiliary help info for which this help applies.
78 HELP_NAME : 'subdirs',
79 # List of help name aliases.
80 HELP_NAME_ALIASES : ['dirs', 'directory', 'directories', 'folder',
81 'folders', 'hierarchy', 'subdir', 'subdirectory',
82 'subdirectories'],
83 # Type of help:
84 HELP_TYPE : HelpType.ADDITIONAL_HELP,
85 # One line summary of this help.
86 HELP_ONE_LINE_SUMMARY : 'How subdirectories work in gsutil',
87 # The full help text.
88 HELP_TEXT : _detailed_help_text,
89 }
OLDNEW
« no previous file with comments | « third_party/gsutil/gslib/addlhelp/projects.py ('k') | third_party/gsutil/gslib/addlhelp/support.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698