datatracker/tastypie/utils/dict.py
Henrik Levkowetz c39925fcd0 Added the tastypie lib to the repository
- Legacy-Id: 8742
2014-12-14 20:28:33 +00:00

20 lines
405 B
Python

from django.utils.encoding import smart_bytes
from django.utils import six
def dict_strip_unicode_keys(uni_dict):
"""
Converts a dict of unicode keys into a dict of ascii keys.
Useful for converting a dict to a kwarg-able format.
"""
if six.PY3:
return uni_dict
data = {}
for key, value in uni_dict.items():
data[smart_bytes(key)] = value
return data