本文整理汇总了Python中botocore.utils.percent_encode方法的典型用法代码示例。如果您正苦于以下问题:Python utils.percent_encode方法的具体用法?Python utils.percent_encode怎么用?Python utils.percent_encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类botocore.utils
的用法示例。
在下文中一共展示了utils.percent_encode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _render_uri_template
# 需要导入模块: from botocore import utils [as 别名]
# 或者: from botocore.utils import percent_encode [as 别名]
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)
示例2: _quote_source_header_from_dict
# 需要导入模块: from botocore import utils [as 别名]
# 或者: from botocore.utils import percent_encode [as 别名]
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
示例3: _quote_source_header
# 需要导入模块: from botocore import utils [as 别名]
# 或者: from botocore.utils import percent_encode [as 别名]
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