Explorar el Código

[utils] Add encode_dict

Sergey M․ hace 10 años
padre
commit
1639282434
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  1. 4 0
      youtube_dl/utils.py

+ 4 - 0
youtube_dl/utils.py

@@ -1638,6 +1638,10 @@ def urlencode_postdata(*args, **kargs):
     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:
     etree_iter = xml.etree.ElementTree.Element.iter
 except AttributeError:  # Python <=2.6