本文整理匯總了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