This file is indexed.

/usr/lib/python3/dist-packages/guiqwt/qtdesigner.py is in python3-guiqwt 3.0.3-2ubuntu1.

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
# -*- coding: utf-8 -*-
#
# Copyright © 2009-2010 CEA
# Pierre Raybaut
# Licensed under the terms of the CECILL License
# (see guiqwt/__init__.py for details)

"""
guiqwt.qtdesigner
-----------------

The `qtdesigner` module provides QtDesigner helper functions for `guiqwt`:
    * :py:func:`guiqwt.qtdesigner.loadui`
    * :py:func:`guiqwt.qtdesigner.compileui`
    * :py:func:`guiqwt.qtdesigner.create_qtdesigner_plugins`
    
Reference
~~~~~~~~~

.. autofunction:: loadui
.. autofunction:: compileui
.. autofunction:: create_qtdesigner_plugin
"""

from guidata.qt import uic
from guidata.qt.QtDesigner import QPyDesignerCustomWidgetPlugin
from guidata.qt.QtGui import QIcon

from guidata.configtools import get_icon
from guidata.py3compat import io


def loadui(fname, replace_class="QwtPlot"):
    """
    Return Widget or Window class from QtDesigner ui file 'fname'
    
    The loadUiType function (PyQt4.uic) doesn't work correctly with guiqwt
    QtDesigner plugins because they don't inheritate from a PyQt4.QtGui
    object.
    """
    uifile_text = open(fname).read().replace(replace_class, "QFrame")
    ui, base_class = uic.loadUiType( io.StringIO(uifile_text) )
    class Form(base_class, ui):
        def __init__(self, parent=None):
            super(Form, self).__init__(parent)
            self.setupUi(self)
    return Form


def compileui(fname, replace_class="QwtPlot"):
    uifile_text = open(fname).read().replace("QwtPlot", "QFrame")
    uic.compileUi(io.StringIO(uifile_text),
                  open(fname.replace(".ui", "_ui.py"), 'w'),
                  pyqt3_wrapper=True )
    
    
def create_qtdesigner_plugin(group, module_name, class_name, widget_options={},
                             icon=None, tooltip="", whatsthis=""):
    """Return a custom QtDesigner plugin class
    
    Example:
    create_qtdesigner_plugin(group = "guiqwt", module_name = "guiqwt.image",
                             class_name = "ImageWidget", icon = "image.png",
                             tooltip = "", whatsthis = ""):
    """
    Widget = getattr(__import__(module_name, fromlist=[class_name]), class_name)
    
    class CustomWidgetPlugin(QPyDesignerCustomWidgetPlugin):
        def __init__(self, parent = None):
            QPyDesignerCustomWidgetPlugin.__init__(self)
            self.initialized = False
    
        def initialize(self, core):
            if self.initialized:
                return
            self.initialized = True
    
        def isInitialized(self):
            return self.initialized
        
        def createWidget(self, parent):
            return Widget(parent, **widget_options)
        
        def name(self):
            return class_name
        
        def group(self):
            return group
        
        def icon(self):
            if icon is not None:
                return get_icon(icon)
            else:
                return QIcon()
            
        def toolTip(self):
            return tooltip
        
        def whatsThis(self):
            return whatsthis
        
        def isContainer(self):
            return False
        
        def domXml(self):
            return '<widget class="%s" name="%s" />\n' % (class_name,
                                                          class_name.lower())
        def includeFile(self):
            return module_name

    return CustomWidgetPlugin