/usr/lib/python2.7/dist-packages/djcelery/compat.py is in python-django-celery 3.1.17-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | from __future__ import absolute_import
import os
import sys
from kombu.utils.encoding import bytes_to_str, str_to_bytes
PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3
def python_2_unicode_compatible(cls):
"""Taken from Django project (django/utils/encoding.py) & modified a bit to
always have __unicode__ method available.
"""
if '__str__' not in cls.__dict__:
raise ValueError("@python_2_unicode_compatible cannot be applied "
"to %s because it doesn't define __str__()." %
cls.__name__)
cls.__unicode__ = cls.__str__
if PY2:
cls.__str__ = lambda self: self.__unicode__().encode('utf-8')
return cls
if PY3:
unicode = str
def itervalues(x):
return x.values()
def setenv(k, v):
os.environ[bytes_to_str(k)] = bytes_to_str(v)
else:
unicode = unicode
def itervalues(x): # noqa
return x.itervalues()
def setenv(k, v): # noqa
os.environ[str_to_bytes(k)] = str_to_bytes(v)
|