This file is indexed.

/usr/lib/python2.7/dist-packages/pymecavideo/standarddragtable.py is in python-mecavideo 6.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
 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
# -*- coding: utf-8 -*-
"""
    table, a module for pymecavideo:
      a subclass of QTableWidget able to send its data by drag & drop
      or to the clipboard.
      
    Copyright (C) 2008 Georges Khaznadar <georgesk@ofset.org>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

import locale

from PyQt4.QtCore import *
from PyQt4.QtGui import *


class standardDragTable(QTableWidget):
    """Implémente une table qui exporte du drag'n drop avec un contenu
    compatible, de type text/html
    """

    def __init__(self, parent):
        QTableWidget.__init__(self, parent)
        QObject.connect(self, SIGNAL("itemSelectionChanged()"), self.selection)
        self.sep_decimal = "."
        try:
            if locale.getdefaultlocale()[0][0:2] == 'fr':
                # en France, le séparateur décimal est la virgule
                self.sep_decimal = ","
        except TypeError:
            pass

    def htmlSelected(self):
        t = "<table>"
        lig_debut = "<tr>"
        for c in range(self.columnCount()):
            lig_debut += "<td>"
            i = self.horizontalHeaderItem(c)
            lig_debut += str(i.text())
            lig_debut += "</td>"
        t += lig_debut + "</tr>"
        for l in range(self.rowCount()):
            lig = "<tr>"
            ok = False  # a priori la ligne pourrait être vide
            for c in range(self.columnCount()):
                lig += "<td>"
                i = self.item(l, c)
                if i and i.isSelected():  # seulement les cases de la sélection
                    lig += str(i.text()).replace(".", self.sep_decimal)
                    ok = True  # la ligne est non vide
                lig += "</td>"
            lig += "</tr>"
            if ok:  # on n'envoie que les lignes non vides
                t += lig
        t += "</table>"
        return t

    def textSelected(self):
        t = ""
        lig_debut = ""
        for c in range(self.columnCount()):
            i = self.horizontalHeaderItem(c)
            lig_debut += str(i.text()) + "\t"
        t += lig_debut[:-1] + "\n"
        for l in range(self.rowCount()):
            lig = ""
            ok = False  # a priori la ligne pourrait être vide
            for c in range(self.columnCount()):
                lig += ""
                i = self.item(l, c)
                if i and i.isSelected():  # seulement les cases de la sélection
                    lig += str(i.text()).replace(".", self.sep_decimal)
                    ok = True  # la ligne est non vide
                lig += "\t"
            if ok:  # on n'envoie que les lignes non vides
                t += lig[:-1] + "\n"
        t += ""
        return t

    def mimeSelected(self):
        mime = QMimeData()
        t = self.htmlSelected()
        mime.setData("text/html", t)
        t = self.textSelected()
        mime.setData("text/plain", t)
        return mime

    def startDrag(self, dropactions):
        drag = QDrag(self)
        mime = self.mimeSelected()
        drag.setMimeData(mime)
        drag.start(Qt.CopyAction)

    def selection(self):
        clip = QApplication.clipboard()
        mime = self.mimeSelected()
        clip.setMimeData(mime)
        # clip.setMimeData(mime, clip.Selection) # ça devrait mettre aussi les données dans le presse papier de la souris pour X11.


if __name__ == "__main__":
    import sys

    app = QApplication([])
    t = standardDragTable(None)
    t.setRowCount(4)
    t.setColumnCount(2)
    t.setGeometry(QRect(0, 0, 400, 300))
    t.setDragEnabled(True)
    for i in range(4):
        for j in range(2):
            t.setItem(i, j, QTableWidgetItem(str(i + j)))
    t.show()
    sys.exit(app.exec_())