This file is indexed.

/usr/share/pyshared/z3c/rml/paraparser.py is in python-z3c.rml 2.0.0-0ubuntu3.

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
 98
 99
100
101
##############################################################################
#
# Copyright (c) 2007-2008 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Paragraph-internal XML parser extensions.

$Id: flowable.py 76814 2007-06-19 20:12:41Z srichter $
"""
__docformat__ = "reStructuredText"

import copy
import inspect

import reportlab.lib.fonts
import reportlab.platypus.paraparser


class PageNumberFragment(reportlab.platypus.paraparser.ParaFrag):
    """A fragment whose `text` is computed at access time."""

    def __init__(self, attributes):
        reportlab.platypus.paraparser.ParaFrag.__init__(self)

    @property
    def text(self):
        # Guess 1: We're in a paragraph in a story.
        frame = inspect.currentframe(4)
        canvas = frame.f_locals.get('canvas', None)

        if canvas is None:
            # Guess 2: We're in a template
            canvas = frame.f_locals.get('canv', None)

        if canvas is None:
            raise Exception("Can't use <pageNumber/> in this location.")

        return str(canvas.getPageNumber())


class GetNameFragment(reportlab.platypus.paraparser.ParaFrag):
    """A fragment whose `text` is computed at access time."""

    def __init__(self, attributes):
        reportlab.platypus.paraparser.ParaFrag.__init__(self)
        self.id = attributes['id']

    @property
    def text(self):
        # Guess 1: We're in a paragraph in a story.
        frame = inspect.currentframe(4)
        canvas = frame.f_locals.get('canvas', None)

        if canvas is None:
            # Guess 2: We're in a template
            canvas = frame.f_locals.get('canv', None)

        if canvas is None:
            raise Exception("Can't use <getName/> in this location.")

        return canvas.manager.names[self.id]


class Z3CParagraphParser(reportlab.platypus.paraparser.ParaParser):
    """Extensions to paragraph-internal XML parsing."""

    def startDynamic(self, attributes, klass):
        frag = klass(attributes)
        frag.__dict__.update(self._stack[-1].__dict__)
        frag.fontName = reportlab.lib.fonts.tt2ps(
            frag.fontName, frag.bold, frag.italic)
        self.fragList.append(frag)
        self._stack.append(frag)

    def endDynamic(self):
        self._pop()

    def start_pageNumber(self, attributes):
        self.startDynamic(attributes, PageNumberFragment)

    def end_pageNumber(self):
        self.endDynamic()

    def start_getName(self, attributes):
        self.startDynamic(attributes, GetNameFragment)

    def end_getName(self):
        self.endDynamic()


# Monkey-patch reportlabs global parser instance. Wah.
import reportlab.platypus.paragraph
reportlab.platypus.paragraph._parser = Z3CParagraphParser()