OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import re | 5 import re |
6 | 6 |
7 | 7 |
8 BUCKET_NAME_REGEX = re.compile(r'^[0-9a-z_\.\-/]{1,100}$') | 8 BUCKET_NAME_REGEX = re.compile(r'^[0-9a-z_\.\-/]{1,100}$') |
9 | 9 |
10 | 10 |
(...skipping 19 matching lines...) Loading... |
30 | 30 |
31 class LeaseExpiredError(Error): | 31 class LeaseExpiredError(Error): |
32 """Raised when provided lease_key does not match the current one.""" | 32 """Raised when provided lease_key does not match the current one.""" |
33 | 33 |
34 | 34 |
35 def validate_bucket_name(bucket): | 35 def validate_bucket_name(bucket): |
36 """Raises InvalidInputError if bucket name is invalid.""" | 36 """Raises InvalidInputError if bucket name is invalid.""" |
37 if not bucket: | 37 if not bucket: |
38 raise InvalidInputError('Bucket not specified') | 38 raise InvalidInputError('Bucket not specified') |
39 if not isinstance(bucket, basestring): | 39 if not isinstance(bucket, basestring): |
40 raise InvalidInputError('Bucket must be a string') | 40 raise InvalidInputError( |
| 41 'Bucket must be a string. It is %s.' % type(bucket).__name__) |
41 if not BUCKET_NAME_REGEX.match(bucket): | 42 if not BUCKET_NAME_REGEX.match(bucket): |
42 raise InvalidInputError( | 43 raise InvalidInputError( |
43 'Bucket name "%s" does not match regular expression %s' % | 44 'Bucket name "%s" does not match regular expression %s' % |
44 (bucket, BUCKET_NAME_REGEX.pattern)) | 45 (bucket, BUCKET_NAME_REGEX.pattern)) |
OLD | NEW |