/usr/share/pyshared/tracrpc/util.py is in trac-xmlrpc 1.1.2+r10706-1.
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 | # -*- coding: utf-8 -*-
"""
License: BSD
(c) 2005-2008 ::: Alec Thomas (alec@swapoff.org)
(c) 2009 ::: www.CodeResort.com - BV Network AS (simon-code@bvnetwork.no)
"""
from trac.util.compat import any
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
try:
# Method only available in Trac 0.11.3 or higher
from trac.util.text import exception_to_unicode
except ImportError:
def exception_to_unicode(e, traceback=""):
from trac.util.text import to_unicode
message = '%s: %s' % (e.__class__.__name__, to_unicode(e))
if traceback:
from trac.util import get_last_traceback
traceback_only = get_last_traceback().split('\n')[:-2]
message = '\n%s\n%s' % (to_unicode('\n'.join(traceback_only)),
message)
return message
try:
# Constant available from Trac 0.12dev r8612
from trac.util.text import empty
except ImportError:
empty = None
def accepts_mimetype(req, mimetype):
if isinstance(mimetype, basestring):
mimetype = (mimetype,)
accept = req.get_header('Accept')
if accept is None :
# Don't make judgements if no MIME type expected and method is GET
return req.method == 'GET'
else :
accept = accept.split(',')
return any(x.strip().startswith(y) for x in accept for y in mimetype)
def prepare_docs(text, indent=4):
r"""Remove leading whitespace"""
return ''.join(l[indent:] for l in text.splitlines(True))
try:
# Micro-second support added to 0.12dev r9210
from trac.util.datefmt import to_utimestamp, from_utimestamp
except ImportError:
from trac.util.datefmt import to_timestamp, to_datetime, utc
to_utimestamp = to_timestamp
from_utimestamp = lambda x: to_datetime(x, utc)
|