This file is indexed.

/usr/lib/python2.7/dist-packages/openpyxl/styles/tests/test_cell_style.py is in python-openpyxl 2.4.9-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
from __future__ import absolute_import
# Copyright (c) 2010-2015 openpyxl
import pytest

from copy import copy

from openpyxl.xml.functions import fromstring, tostring
from openpyxl.tests.helper import compare_xml


@pytest.fixture
def StyleArray():
    from ..cell_style import StyleArray
    return StyleArray


class TestStyleArray:


    def test_ctor(self, StyleArray):
        style = StyleArray(range(9))
        assert style.fontId == 0
        assert style.numFmtId == 3
        assert style.xfId == 8


    def test_hash(self, StyleArray):
        s1 = StyleArray((range(9)))
        s2 = StyleArray((range(9)))
        assert hash(s1) == hash(s2)


    def test_copy(self, StyleArray):
        s1 = StyleArray((range(9)))
        s2 = copy(s1)
        assert type(s1) == type(s2)
        assert s1 == s2


@pytest.fixture
def CellStyle():
    from ..cell_style import CellStyle
    return CellStyle


class TestCellStyle:

    def test_ctor(self, CellStyle):
        cell_style = CellStyle(xfId=0)
        xml = tostring(cell_style.to_tree())
        expected = """
        <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" />
        """
        diff = compare_xml(xml, expected)
        assert diff is None, diff


    def test_from_xml(self, CellStyle):
        from ..alignment import Alignment
        src = """
        <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
          <alignment horizontal="center"/>
        </xf>
        """
        node = fromstring(src)
        cell_style = CellStyle.from_tree(node)
        assert cell_style == CellStyle(
            alignment=Alignment(horizontal="center"),
            applyAlignment=True,
            xfId=0,
        )


    def test_to_array(self, CellStyle):
        from ..cell_style import StyleArray
        xf = CellStyle(
            numFmtId=43,
            fontId=1,
            fillId=2,
            borderId=4,
            xfId=None,
            quotePrefix=True,
            pivotButton=True,
            applyNumberFormat=None,
            applyFont=None,
            applyFill=None,
            applyBorder=None,
            applyAlignment=None,
            applyProtection=None,
            alignment=None,
            protection=None,
        )
        style = xf.to_array()
        assert style == StyleArray([1, 2, 4, 43, 0, 0, 1, 1, 0])


    def test_from_array(self, CellStyle):
        from ..cell_style import StyleArray
        style = StyleArray([5, 10, 15, 0, 0, 0, 1, 1, 15])
        xf = CellStyle.from_array(style)
        assert dict(xf) == {'borderId': '15', 'fillId': '10', 'fontId': '5',
                            'numFmtId': '0', 'pivotButton': '1', 'quotePrefix': '1', 'xfId':
                            '15'}


@pytest.fixture
def CellStyleList():
    from ..cell_style import CellStyleList
    return CellStyleList


class TestCellStyleList:

    def test_ctor(self, CellStyleList):
        cell_style = CellStyleList()
        xml = tostring(cell_style.to_tree())
        expected = """
        <cellXfs count="0"/>
        """
        diff = compare_xml(xml, expected)
        assert diff is None, diff


    def test_from_xml(self, CellStyleList):
        src = """
        <cellXfs count="0" />
        """
        node = fromstring(src)
        cell_style = CellStyleList.from_tree(node)
        assert cell_style == CellStyleList()


    def test_to_array(self, CellStyleList):
        src = """
        <cellXfs count="29">
            <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
            <xf numFmtId="0" fontId="3" fillId="0" borderId="0" xfId="0" applyFont="1"/>
            <xf numFmtId="0" fontId="4" fillId="0" borderId="0" xfId="0" applyFont="1"/>
            <xf numFmtId="0" fontId="5" fillId="0" borderId="0" xfId="0" applyFont="1"/>
            <xf numFmtId="0" fontId="6" fillId="0" borderId="0" xfId="0" applyFont="1"/>
            <xf numFmtId="0" fontId="7" fillId="0" borderId="0" xfId="0" applyFont="1"/>
            <xf numFmtId="0" fontId="0" fillId="2" borderId="0" xfId="0" applyFill="1"/>
            <xf numFmtId="0" fontId="0" fillId="3" borderId="0" xfId="0" applyFill="1"/>
            <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
              <alignment horizontal="left"/>
            </xf>
            <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
              <alignment horizontal="right"/>
            </xf>
            <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
              <alignment horizontal="center"/>
            </xf>
            <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
              <alignment vertical="top"/>
            </xf>
            <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
              <alignment vertical="center"/>
            </xf>
            <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1"/>
            <xf numFmtId="2" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>
            <xf numFmtId="14" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>
            <xf numFmtId="10" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>
            <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
              <alignment horizontal="center"/>
            </xf>
            <xf numFmtId="0" fontId="0" fillId="0" borderId="1" xfId="0" applyBorder="1"/>
            <xf numFmtId="0" fontId="0" fillId="0" borderId="2" xfId="0" applyBorder="1"/>
            <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
              <alignment wrapText="1"/>
            </xf>
            <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
              <alignment shrinkToFit="1"/>
            </xf>
            <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyFill="1" applyBorder="1"/>
            <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
              <alignment horizontal="center"/>
            </xf>
            <xf numFmtId="0" fontId="0" fillId="4" borderId="3" xfId="0" applyFill="1" applyBorder="1" applyAlignment="1">
              <alignment horizontal="center" vertical="center"/>
            </xf>
            <xf numFmtId="0" fontId="0" fillId="4" borderId="4" xfId="0" applyFill="1" applyBorder="1" applyAlignment="1">
              <alignment horizontal="center" vertical="center"/>
            </xf>
            <xf numFmtId="0" fontId="0" fillId="4" borderId="5" xfId="0" applyFill="1" applyBorder="1" applyAlignment="1">
              <alignment horizontal="center" vertical="center"/>
            </xf>
            <xf numFmtId="0" fontId="0" fillId="4" borderId="6" xfId="0" applyFill="1" applyBorder="1" applyAlignment="1">
              <alignment horizontal="center" vertical="center"/>
            </xf>
            <xf numFmtId="0" fontId="6" fillId="5" borderId="0" xfId="0" applyFont="1" applyFill="1"/>
        </cellXfs>
        """
        node = fromstring(src)
        xfs = CellStyleList.from_tree(node)
        styles = xfs._to_array()
        assert len(styles) == 29
        assert len(xfs.alignments) == 9
        assert len(xfs.prots) == 1