1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-23 00:54:31 +01:00

[utils] Add encode_dict

This commit is contained in:
Sergey M․ 2015-09-06 07:22:20 +06:00
parent be0e5dbd83
commit 1639282434

View File

@ -1638,6 +1638,10 @@ def urlencode_postdata(*args, **kargs):
return compat_urllib_parse.urlencode(*args, **kargs).encode('ascii') return compat_urllib_parse.urlencode(*args, **kargs).encode('ascii')
def encode_dict(d, encoding='utf-8'):
return dict((k.encode(encoding), v.encode(encoding)) for k, v in d.items())
try: try:
etree_iter = xml.etree.ElementTree.Element.iter etree_iter = xml.etree.ElementTree.Element.iter
except AttributeError: # Python <=2.6 except AttributeError: # Python <=2.6