/usr/share/pyshared/djcelery/admin_utils.py is in python-django-celery 2.5.5-2.
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
from pprint import pformat
from django.utils.html import escape
def attrs(**kwargs):
def _inner(fun):
for attr_name, attr_value in kwargs.items():
setattr(fun, attr_name, attr_value)
return fun
return _inner
def display_field(short_description, admin_order_field, allow_tags=True,
**kwargs):
return attrs(short_description=short_description,
admin_order_field=admin_order_field,
allow_tags=allow_tags, **kwargs)
def action(short_description, **kwargs):
return attrs(short_description=short_description, **kwargs)
def fixedwidth(field, name=None, pt=6, width=16, maxlen=64, pretty=False):
@display_field(name or field, field)
def f(task):
val = getattr(task, field)
if pretty:
val = pformat(val, width=width)
if val.startswith("u'") or val.startswith('u"'):
val = val[2:-1]
shortval = val.replace(",", ",\n")
shortval = shortval.replace("\n", "|br/|")
if len(shortval) > maxlen:
shortval = shortval[:maxlen] + "..."
return """<span title="%s", style="font-size: %spt;\
font-family: Menlo, Courier; ">%s</span>""" % (
escape(val[:255]), pt, escape(shortval)).replace("|br/|", "<br/>")
return f
|