This file is indexed.

/usr/lib/python2.7/dist-packages/openpyxl/comments/tests/test_comment_sheet.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
from __future__ import absolute_import
# Copyright (c) 2010-2017 openpyxl
import pytest

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


def _comment_list():
    from ..comments import Comment
    wb = Workbook()
    ws = wb.active
    comment1 = Comment("text", "author")
    comment2 = Comment("text2", "author2")
    comment3 = Comment("text3", "author3")
    ws["B2"].comment = comment1
    ws["C7"].comment = comment2
    ws["D9"].comment = comment3

    comments = []
    for coord, cell in sorted(ws._cells.items()):
        if cell._comment is not None:
            comment = CommentRecord.from_cell(cell)
            comments.append(comment)

    return comments


class TestComment:

    def test_ctor(self):
        comment = CommentRecord()
        comment.text.t = "Some kind of comment"
        xml = tostring(comment.to_tree())
        expected = """
        <comment authorId="0" ref="" shapeId="0">
          <text>
            <t>Some kind of comment</t>
          </text>
        </comment>
        """
        diff = compare_xml(xml, expected)
        assert diff is None, diff


    def test_from_xml(self):
        src = """
        <comment authorId="0" ref="A1">
          <text></text>
        </comment>
        """
        node = fromstring(src)
        comment = CommentRecord.from_tree(node)
        assert comment == CommentRecord(ref="A1")


class TestCommentSheet:


    def test_read_comments(self, datadir):
        from ..comment_sheet import CommentSheet

        datadir.chdir()
        with open("comments1.xml") as src:
            node = fromstring(src.read())

        comments = CommentSheet.from_tree(node)
        assert comments.authors.author == ['author2', 'author', 'author3']
        assert len(comments.commentList) == 3


    def test_from_comments(self, datadir):
        from .. comment_sheet import CommentSheet
        datadir.chdir()
        comments = _comment_list()
        cs = CommentSheet.from_comments(comments)
        xml = tostring(cs.to_tree())

        with open('comments_out.xml') as src:
            expected = src.read()

        diff = compare_xml(xml, expected)
        assert diff is None, diff


    def test_path(self):
        from ..comment_sheet import CommentSheet
        from ..author import AuthorList
        cs = CommentSheet(authors=AuthorList(), commentList=())
        assert cs.path == '/xl/comments/commentNone.xml'


def test_read_google_docs(datadir):
    datadir.chdir()
    xml = """
    <comment authorId="0" ref="A1">
      <text>
        <t xml:space="preserve">some comment
	 -Peter Lustig</t>
      </text>
    </comment>
    """
    node = fromstring(xml)
    comment = CommentRecord.from_tree(node)
    assert comment.text.t == "some comment\n\t -Peter Lustig"