Esempio n. 1
0
def _quote_source_header(value):
    result = VERSION_ID_SUFFIX.search(value)
    if result is None:
        return percent_encode(value, safe=SAFE_CHARS + '/')
    else:
        first, version_id = value[:result.start()], value[result.start():]
        return percent_encode(first, safe=SAFE_CHARS + '/') + version_id
Esempio n. 2
0
def _quote_source_header(value):
    result = VERSION_ID_SUFFIX.search(value)
    if result is None:
        return percent_encode(value, safe=SAFE_CHARS + '/')
    else:
        first, version_id = value[:result.start()], value[result.start():]
        return percent_encode(first, safe=SAFE_CHARS + '/') + version_id
Esempio n. 3
0
 def is_excluded(self, key):
     for exclude in self.excludes:
         if key.startswith(exclude):
             return True
     try:
         percent_encode(key)
     except UnicodeEncodeError as e:
         self.log_error('{} - {}'.format(key, str(e)), error_type='name')
         return True
     return False
 def _render_uri_template(self, uri_template, params):
     # We need to handle two cases::
     #
     # /{Bucket}/foo
     # /{Key+}/bar
     # A label ending with '+' is greedy.  There can only
     # be one greedy key.
     encoded_params = {}
     for template_param in re.findall(r'{(.*?)}', uri_template):
         if template_param.endswith('+'):
             encoded_params[template_param] = percent_encode(
                 params[template_param[:-1]], safe='/~')
         else:
             encoded_params[template_param] = percent_encode(
                 params[template_param])
     return uri_template.format(**encoded_params)
Esempio n. 5
0
 def _render_uri_template(self, uri_template, params):
     # We need to handle two cases::
     #
     # /{Bucket}/foo
     # /{Key+}/bar
     # A label ending with '+' is greedy.  There can only
     # be one greedy key.
     encoded_params = {}
     for template_param in re.findall(r'{(.*?)}', uri_template):
         if template_param.endswith('+'):
             encoded_params[template_param] = percent_encode(
                 params[template_param[:-1]], safe='/~')
         else:
             encoded_params[template_param] = percent_encode(
                 params[template_param])
     return uri_template.format(**encoded_params)
Esempio n. 6
0
def _quote_source_header_from_dict(source_dict):
    try:
        bucket = source_dict["Bucket"]
        key = percent_encode(source_dict["Key"], safe=SAFE_CHARS + "/")
        version_id = source_dict.get("VersionId")
    except KeyError as e:
        raise ParamValidationError(report="Missing required parameter: %s" % str(e))
    final = "%s/%s" % (bucket, key)
    if version_id is not None:
        final += "?versionId=%s" % version_id
    return final
def _quote_source_header_from_dict(source_dict):
    try:
        bucket = source_dict['Bucket']
        key = percent_encode(source_dict['Key'], safe=SAFE_CHARS + '/')
        version_id = source_dict.get('VersionId')
    except KeyError as e:
        raise ParamValidationError(report='Missing required parameter: %s' %
                                   str(e))
    final = '%s/%s' % (bucket, key)
    if version_id is not None:
        final += '?versionId=%s' % version_id
    return final
Esempio n. 8
0
def _quote_source_header_from_dict(source_dict):
    try:
        bucket = source_dict['Bucket']
        key = percent_encode(source_dict['Key'], safe=SAFE_CHARS + '/')
        version_id = source_dict.get('VersionId')
    except KeyError as e:
        raise ParamValidationError(
            report='Missing required parameter: %s' % str(e))
    final =  '%s/%s' % (bucket, key)
    if version_id is not None:
        final += '?versionId=%s' % version_id
    return final