This file is indexed.

/usr/share/pyshared/seqdiag/elements.py is in python-seqdiag 0.9.0-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
 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# -*- coding: utf-8 -*-
#  Copyright 2011 Takeshi KOMIYA
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

import re
import sys
import blockdiag.elements
from blockdiag.utils import images, Size, XY


class NodeGroup(blockdiag.elements.NodeGroup):
    pass


class DiagramNode(blockdiag.elements.DiagramNode):
    def __init__(self, _id):
        super(DiagramNode, self).__init__(_id)

        self.activated = False
        self.activity = []
        self.activities = []

    def set_activated(self, value):
        self.activated = True

    def activate(self, height, index):
        if len(self.activity) <= index:
            self.activity.insert(index, [])

        if (len(self.activity[index]) > 0 and
           (self.activity[index][-1] != height - 1)):
            self.deactivate(index)

        self.activity[index].append(height)

    def deactivate(self, index=None):
        if index is None:
            for i in range(len(self.activity)):
                self.deactivate(i)
            return

        if self.activity[index]:
            attr = {'lifetime': self.activity[index],
                    'level': index}
            self.activities.append(attr)

        self.activity[index] = []


class EdgeSeparator(blockdiag.elements.Base):
    basecolor = (208, 208, 208)
    linecolor = (0, 0, 0)

    @classmethod
    def clear(cls):
        super(EdgeSeparator, cls).clear()
        cls.basecolor = (208, 208, 208)
        cls.linecolor = (0, 0, 0)

    def __init__(self, _type, label):
        super(EdgeSeparator, self).__init__()
        self.label = label
        self.group = None
        self.style = None
        self.color = self.basecolor
        self.order = 0

        if _type == '===':
            self.type = 'divider'
        elif _type == '...':
            self.type = 'delay'


class DiagramEdge(blockdiag.elements.DiagramEdge):
    notecolor = (255, 182, 193)  # LightPink

    @classmethod
    def clear(cls):
        super(DiagramEdge, cls).clear()
        cls.notecolor = (255, 182, 193)

    @classmethod
    def set_default_note_color(cls, color):
        color = images.color_to_rgb(color)
        cls.notecolor = color

    def __init__(self, node1, node2):
        super(DiagramEdge, self).__init__(node1, node2)

        self.leftnote = None
        self.leftnotesize = Size(0, 0)
        self.rightnote = None
        self.rightnotesize = Size(0, 0)
        self.textwidth = 0
        self.textheight = 0
        self.order = 0
        self.activate = True
        self.async = False
        self.diagonal = False
        self.failed = False
        self.return_label = ''

    @property
    def left_node(self):
        if self.node1.xy.x <= self.node2.xy.x:
            return self.node1
        else:
            return self.node2

    @property
    def right_node(self):
        if self.node1.xy.x > self.node2.xy.x:
            return self.node1
        else:
            return self.node2

    @property
    def direction(self):
        if self.node1.xy.x == self.node2.xy.x:
            direction = 'self'
        elif self.node1.xy.x < self.node2.xy.x:
            # n1 .. n2
            if self.dir == 'forward':
                direction = 'right'
            else:
                direction = 'left'
        else:
            # n2 .. n1
            if self.dir == 'forward':
                direction = 'left'
            else:
                direction = 'right'

        return direction

    def set_note(self, value):
        self.rightnote = value

    def set_diagonal(self, value):
        self.diagonal = True

    def set_async(self, value):
        self.dir = 'forward'

    def set_return(self, value):
        self.return_label = value

    def set_failed(self, value):
        self.failed = True
        self.activate = False

    def set_activate(self, value):
        self.activate = True

    def set_noactivate(self, value):
        self.activate = False

    def set_dir(self, value):
        _dir = value.lower()
        if _dir in ('back', 'both', 'forward'):
            self.dir = _dir
        elif _dir == '=>':
            self.dir = 'both'
        elif _dir in ('->', '->>', '-->', '-->>'):
            self.dir = 'forward'

            if re.search('--', _dir):
                self.style = 'dashed'
            else:
                self.style = None

            if re.search('>>', _dir):
                self.async = True
            else:
                self.async = False
        elif _dir in ('<-', '<<-', '<--', '<<--'):
            self.dir = 'back'

            if re.search('--', _dir):
                self.style = 'dashed'
            else:
                self.style = None

            if re.search('<<', _dir):
                self.async = True
            else:
                self.async = False
        else:
            msg = "WARNING: unknown edge dir: %s\n" % _dir
            sys.stderr.write(msg)


class AltBlock(blockdiag.elements.Base):
    basecolor = (0, 0, 0)
    linecolor = (0, 0, 0)
    width = None
    height = None

    @classmethod
    def clear(cls):
        super(EdgeSeparator, cls).clear()
        cls.basecolor = (0, 0, 0)
        cls.linecolor = (0, 0, 0)

    @classmethod
    def set_default_linecolor(cls, color):
        color = images.color_to_rgb(color)
        cls.linecolor = color

    def __init__(self, _type, _id):
        self.type = _type
        self.id = _id
        self.xlevel = 1
        self.ylevel_top = 1
        self.ylevel_bottom = 1
        self.edges = []
        self.color = self.basecolor

    @property
    def xy(self):
        if len(self.edges) == 0:
            return XY(0, 0)
        else:
            x = min(e.left_node.xy.x for e in self.edges)
            y = min(e.order for e in self.edges) + 1
            return XY(x, y)

    @property
    def colwidth(self):
        if len(self.edges) == 0:
            return 1
        else:
            x2 = max(e.right_node.xy.x for e in self.edges)
            return x2 - self.xy.x + 1

    @property
    def colheight(self):
        if len(self.edges) == 0:
            return 1
        else:
            y2 = max(e.order for e in self.edges) + 1
            return y2 - self.xy.y + 1


class Diagram(blockdiag.elements.Diagram):
    _DiagramNode = DiagramNode
    _DiagramEdge = DiagramEdge

    def __init__(self):
        super(Diagram, self).__init__()

        self.int_attrs.append('edge_length')

        self.activation = True
        self.autonumber = False
        self.edge_length = None
        self.groups = []
        self.separators = []
        self.altblocks = []

    def traverse_groups(self, preorder=False):
        return self.groups

    def set_default_linecolor(self, color):
        super(Diagram, self).set_default_linecolor(color)

        color = images.color_to_rgb(color)
        AltBlock.set_default_linecolor(color)

    def set_default_note_color(self, color):
        color = images.color_to_rgb(color)
        self._DiagramEdge.set_default_note_color(color)

    def set_activation(self, value):
        value = value.lower()
        if value == 'none':
            self.activation = value
        else:
            msg = "WARNING: unknown activation style: %s\n" % value
            sys.stderr.write(msg)

    def set_autonumber(self, value):
        if value.lower() == 'false':
            self.autonumber = False
        else:
            self.autonumber = True

    def set_edge_height(self, value):
        msg = "WARNING: edge_height is obsoleted; use span_height\n"
        sys.stderr.write(msg)

        self.span_height = int(value)