@staticmethod<EOL><INDENT>def amz_cano_querystring(qs):<DEDENT>
safe_qs_amz_chars = '<STR_LIT>'<EOL>safe_qs_unresvd = '<STR_LIT>'<EOL>if PY2:<EOL><INDENT>qs = qs.encode('<STR_LIT:utf-8>')<EOL>safe_qs_amz_chars = safe_qs_amz_chars.encode()<EOL>safe_qs_unresvd = safe_qs_unresvd.encode()<EOL><DEDENT>qs = unquote(qs)<EOL>space = b'<STR_LIT:U+0020>' if PY2 else '<STR_LIT:U+0020>'<EOL>qs = qs.split(space)[<NUM_LIT:0>]<EOL>qs = quote(qs, safe=safe_qs_amz_chars)<EOL>qs_items = {}<EOL>for name, vals in parse_qs(qs, keep_blank_values=True).items():<EOL><INDENT>name = quote(name, safe=safe_qs_unresvd)<EOL>vals = [quote(val, safe=safe_qs_unresvd) for val in vals]<EOL>qs_items[name] = vals<EOL><DEDENT>qs_strings = []<EOL>for name, vals in qs_items.items():<EOL><INDENT>for val in vals:<EOL><INDENT>qs_strings.append('<STR_LIT:=>'.join([name, val]))<EOL><DEDENT><DEDENT>qs = '<STR_LIT:&>'.join(sorted(qs_strings))<EOL>if PY2:<EOL><INDENT>qs = unicode(qs)<EOL><DEDENT>return qs<EOL>
Parse and format querystring as per AWS4 auth requirements.

Perform percent quoting as needed.

qs -- querystring