(params, arg_name)
| 121 | |
| 122 | |
| 123 | def validate_s3_location(params, arg_name): |
| 124 | arg_name = arg_name.replace('-', '_') |
| 125 | if arg_name in params: |
| 126 | s3_location = getattr(params, arg_name) |
| 127 | if s3_location: |
| 128 | matcher = re.match('s3://(.+?)/(.+)', str(s3_location)) |
| 129 | if matcher: |
| 130 | params.bucket = matcher.group(1) |
| 131 | params.key = matcher.group(2) |
| 132 | else: |
| 133 | raise ParamValidationError( |
| 134 | '--{0} must specify the Amazon S3 URL format as ' |
| 135 | 's3://<bucket>/<key>.'.format(arg_name.replace('_', '-')) |
| 136 | ) |