/usr/lib/python2.7/dist-packages/kopano/compat.py is in python-kopano 8.5.5-0ubuntu1.
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | """
Part of the high-level python bindings for Kopano
Copyright 2005 - 2016 Zarafa and its licensors (see LICENSE file)
Copyright 2016 - Kopano and its licensors (see LICENSE file)
"""
try:
import cPickle as pickle
except ImportError:
import pickle
try:
from functools import lru_cache
except ImportError:
from .lru_cache import lru_cache
try:
from StringIO import StringIO
except ImportError:
# We only need it for Python 2
pass
import codecs
import io
import sys
# Python 3
if sys.hexversion >= 0x03000000:
def is_str(s):
return isinstance(s, str)
def pickle_load(f):
return pickle.load(f, encoding='bytes')
def pickle_loads(s):
return pickle.loads(s, encoding='bytes')
def hex(s):
return codecs.encode(s, 'hex').upper().decode('ascii')
def unhex(s):
return codecs.decode(s, 'hex')
def is_int(i):
return isinstance(i, int)
def is_file(f):
return isinstance(f, io.IOBase)
def repr(o):
return o.__unicode__()
def fake_unicode(s):
return str(s)
def decode(s):
return s
def encode(s):
return s.encode()
# Python 2
else:
def is_str(s):
return isinstance(s, (str, unicode))
def pickle_load(f):
return pickle.loads(f)
def pickle_loads(s):
return pickle.loads(s)
def hex(s):
return s.encode('hex').upper()
def unhex(s):
return s.decode('hex')
def is_int(i):
return isinstance(i, (int, long))
def is_file(f):
return isinstance(f, file) or isinstance(f, StringIO)
def encode(s):
# sys.stdout can be StringIO (nosetests)
return s.encode(getattr(sys.stdout, 'encoding', 'utf8') or 'utf8')
def decode(s):
return s.decode(getattr(sys.stdin, 'encoding', 'utf8') or 'utf8')
def repr(o):
return encode(unicode(o))
def fake_unicode(u):
return unicode(u)
|