/usr/lib/python2.7/dist-packages/wikitable/scalar.py is in trac-wikitablemacro 1:0.3-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 | # -*- coding: utf-8 -*-
#
# Copyright (C) 2008 Martin Aspeli <optilude@gmail.com>
# Copyright (C) 2012-2105 Ryan J Ollos <ryan.j.ollos@gmail.com>
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution.
#
from trac.web.chrome import add_stylesheet
from trac.wiki.formatter import system_message
from trac.wiki.macros import WikiMacroBase
from trac.util.html import html as tag
from trac.util.text import exception_to_unicode
from trac.util.translation import _
class SQLScalar(WikiMacroBase):
"""Output a number from a scalar (1x1) SQL query.
Examples:
{{{
{{{
#!SQLScalar
SELECT count(id) as 'Number of Tickets'
FROM ticket
}}}
}}}
"""
# IWikiMacroBase methods
def expand_macro(self, formatter, name, content):
try:
rows = self.env.db_query(content)
except self.env.db_exc.DatabaseError, e:
return system_message(_("Invalid SQL"), exception_to_unicode(e))
else:
value = rows[0][0] if len(rows) else "(NULL)"
add_stylesheet(formatter.req, 'wikitable/css/wikitable.css')
return tag.span(value, class_='wikiscalar')
|