summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Schwartz <mfschwartz@google.com>2010-08-26 17:54:45 -0700
committerMike Schwartz <mfschwartz@google.com>2010-08-26 17:54:45 -0700
commit1c09b0ee7506039f29cf4251674def7cdc285bad (patch)
tree8ff475325043f5dca1adb4bc8fd8f240ff2627cf
parent955a1c755b3857d2ae9f5b121ae336a6d947b7de (diff)
downloadboto-1c09b0ee7506039f29cf4251674def7cdc285bad.tar.gz
Made storage_uri factory method enforce syntax that URIs be of form "scheme://" not "scheme:"
-rw-r--r--boto/__init__.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/boto/__init__.py b/boto/__init__.py
index 50c5c0fe..99160975 100644
--- a/boto/__init__.py
+++ b/boto/__init__.py
@@ -357,11 +357,16 @@ def storage_uri(uri_str, default_scheme='file', debug=False, validate=True):
# (the latter includes an optional host/net location part).
end_scheme_idx = uri_str.find('://')
if end_scheme_idx == -1:
- scheme = default_scheme.lower()
- path = uri_str
+ # Check for common error: user specifies gs:bucket instead
+ # of gs://bucket. Some URI parsers allow this, but it can cause
+ # confusion for callers, so we don't.
+ if uri_str.find(':'):
+ raise InvalidUriError('"%s" contains ":" instead of "://"' % uri_str)
+ scheme = default_scheme.lower()
+ path = uri_str
else:
- scheme = uri_str[0:end_scheme_idx].lower()
- path = uri_str[end_scheme_idx + 3:]
+ scheme = uri_str[0:end_scheme_idx].lower()
+ path = uri_str[end_scheme_idx + 3:]
if scheme not in ['file', 's3', 'gs']:
raise InvalidUriError('Unrecognized scheme "%s"' % scheme)