-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chore/python3 #39
Chore/python3 #39
Changes from 1 commit
5fd502f
93b991a
03b6cc4
ae9d5d2
1827c60
45714ac
117a20a
73e0056
ae79cdc
043f8de
7b44918
738a1b9
2a1aedd
b189628
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ | |
try: | ||
from urllib.parse import urlparse, parse_qs, quote, unquote, quote_plus | ||
except ImportError: | ||
from urlparse import urlparse, parse_qs | ||
from urllib import quote, unquote, quote_plus | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was Python 3 compatible, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, right, i will just remove the |
||
from urllib.parse import urlparse, parse_qs | ||
from urllib.parse import quote, unquote, quote_plus | ||
|
||
def set_req_date(req, req_date): | ||
if constants.REQUEST_DATE_HEADER in req.headers: | ||
|
@@ -110,10 +110,10 @@ def generate_presigned_url(url, method, access_key, signing_key, request_date, e | |
querystring[constants.AWS_SIGNED_HEADERS_KEY] = 'host' | ||
|
||
canonical_qs = '' | ||
for key in sorted(querystring.iterkeys()): | ||
for key in sorted(querystring.keys()): | ||
canonical_qs += '&' + key + '=' + querystring[key] | ||
canonical_qs = canonical_qs[1:] | ||
for key in sorted(additional_signed_qs.iterkeys()): | ||
for key in sorted(additional_signed_qs.keys()): | ||
canonical_qs += '&' + key + '=' + quote_plus(additional_signed_qs[key]) | ||
|
||
url_parts = url.split('://') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,8 @@ | |
try: | ||
from urllib.parse import urlparse, parse_qs, quote, unquote | ||
except ImportError: | ||
from urlparse import urlparse, parse_qs | ||
from urllib import quote, unquote | ||
paulineribeyre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from urllib.parse import urlparse, parse_qs | ||
from urllib.parse import quote, unquote | ||
|
||
|
||
DEFAULT_INCLUDE_HEADERS = [ | ||
|
@@ -119,7 +119,7 @@ def normalize_date_format(date_str): | |
} | ||
|
||
out_date = None | ||
for regex, xform in formats.items(): | ||
for regex, xform in list(formats.items()): | ||
m = re.search(regex, date_str) | ||
if m: | ||
out_date = xform(m) | ||
|
@@ -224,7 +224,7 @@ def get_canonical_headers(req, include=None): | |
# Requests, since it uses a case-insensitive dict to hold headers, this | ||
# is here just in case you duck type with a regular dict | ||
cano_headers_dict = {} | ||
for hdr, val in headers.items(): | ||
for hdr, val in list(headers.items()): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. useless |
||
hdr = hdr.strip().lower() | ||
val = normalize_whitespace(val).strip() | ||
if (hdr in include or '*' in include or | ||
|
@@ -280,7 +280,7 @@ def format_cano_path(path): | |
qm = b'?' if PY2 else '?' | ||
full_path = qm.join((full_path, qs)) | ||
if PY2: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still need these |
||
full_path = unicode(full_path) | ||
full_path = str(full_path) | ||
return full_path | ||
|
||
|
||
|
@@ -306,17 +306,17 @@ def format_cano_querystring(qs): | |
qs = qs.split(space)[0] | ||
qs = quote(qs, safe=safe_qs_amz_chars) | ||
qs_items = {} | ||
for name, vals in parse_qs(qs, keep_blank_values=True).items(): | ||
for name, vals in list(parse_qs(qs, keep_blank_values=True).items()): | ||
paulineribeyre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name = quote(name, safe=safe_qs_unresvd) | ||
vals = [quote(val, safe=safe_qs_unresvd) for val in vals] | ||
qs_items[name] = vals | ||
qs_strings = [] | ||
for name, vals in qs_items.items(): | ||
for name, vals in list(qs_items.items()): | ||
paulineribeyre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for val in vals: | ||
qs_strings.append('='.join([name, val])) | ||
qs = '&'.join(sorted(qs_strings)) | ||
if PY2: | ||
qs = unicode(qs) | ||
qs = str(qs) | ||
return qs | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about: