]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[utils] Add encode_dict
authorSergey M․ <dstftw@gmail.com>
Sun, 6 Sep 2015 01:22:20 +0000 (07:22 +0600)
committerSergey M․ <dstftw@gmail.com>
Sun, 6 Sep 2015 01:22:20 +0000 (07:22 +0600)
youtube_dl/utils.py

index 7cf91ac192f89cf75e6d75869b3ee12976e2ada3..5529d5291cda4df65279525eb581b475cb19dca9 100644 (file)
@@ -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