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

Side by Side Diff: third_party/gsutil/gslib/storage_uri_builder.py

Issue 2280023003: depot_tools: Remove third_party/gsutil (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « third_party/gsutil/gslib/project_id.py ('k') | third_party/gsutil/gslib/thread_pool.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2012 Google Inc. All Rights Reserved.
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 """
16 Class that holds state (bucket_storage_uri_class and debug) needed for
17 instantiating StorageUri objects. The StorageUri func defined in this class
18 uses that state plus gsutil default flag values to instantiate this frequently
19 constructed object with just one param for most cases.
20 """
21
22 import boto
23 from gslib.exception import CommandException
24
25
26 class StorageUriBuilder(object):
27
28 def __init__(self, debug, bucket_storage_uri_class):
29 """
30 Args:
31 debug: Debug level to pass in to boto connection (range 0..3).
32 bucket_storage_uri_class: Class to instantiate for cloud StorageUris.
33 Settable for testing/mocking.
34 """
35 self.bucket_storage_uri_class = bucket_storage_uri_class
36 self.debug = debug
37
38 def StorageUri(self, uri_str, is_latest=False):
39 """
40 Instantiates StorageUri using class state and gsutil default flag values.
41
42 Args:
43 uri_str: StorageUri naming bucket or object.
44 is_latest: boolean indicating whether this versioned object represents the
45 current version.
46
47 Returns:
48 boto.StorageUri for given uri_str.
49
50 Raises:
51 InvalidUriError: if uri_str not valid.
52 """
53 return boto.storage_uri(
54 uri_str, 'file', debug=self.debug, validate=False,
55 bucket_storage_uri_class=self.bucket_storage_uri_class,
56 suppress_consec_slashes=False, is_latest=is_latest)
OLDNEW
« no previous file with comments | « third_party/gsutil/gslib/project_id.py ('k') | third_party/gsutil/gslib/thread_pool.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698