Exemple #1
0
 def makeItem(parent, name, value="", color=None, font=None,
              expand=True, span=False):
     item = QtGui.QTreeWidgetItem(parent)
     nLabel = QtGui.QLabel(tree)
     nLabel.setText(utils.decode(name))
     item.setSizeHint(0, nLabel.sizeHint() + QtCore.QSize(10, 0))
     tree.setItemWidget(item, 0, nLabel)
     if font is not None:
         nLabel.setFont(font)
     if span:
         item.setFirstColumnSpanned(True)
     else:
         vLabel = QtGui.QLabel(tree)
         vLabel.setMinimumWidth(self._treeWidget.sizeHint().width() -
                                self._treeWidget.columnWidth(0) - 1)
         tree.setItemWidget(item, 1, vLabel)
         if color:
             vLabel.setText(u"<font color=\"%s\">%s</font>"
                            % (color.color().name(),
                               utils.decode(value)))
         else:
             vLabel.setText(utils.decode(value))
         vLabel.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
         item.setSizeHint(1, QtCore.QSize(vLabel.sizeHint().width() + 10,
                                          vLabel.sizeHint().height()))
     if expand:
         item.setExpanded(True)
     return item
Exemple #2
0
 def _setText(self):
     '''
     Sets text of searched widgets.
     '''
     self._stopSearching()
     self._text = decode(self.plainTextEditText.toPlainText()).strip()
     self._saveState()
Exemple #3
0
 def _setName(self, name):
     '''
     Sets the name of searched widgets.
     '''
     if self._manualUpdate:
         return
     self._stopSearching()
     self._name = decode(name).strip()
Exemple #4
0
 def _setRole(self, role):
     '''
     Sets the role of searched widgets.
     '''
     if self._manualUpdate:
         return
     self._stopSearching()
     self._role = decode(role).strip()
Exemple #5
0
 def _setName(self, name):
     '''
     Sets the name of searched widgets.
     '''
     if self._manualUpdate:
         return
     self._stopSearching()
     self._name = decode(name).strip()
Exemple #6
0
 def _setState(self, state):
     '''
     Sets the state of searched widgets.
     '''
     if self._manualUpdate:
         return
     self._stopSearching()
     self._state = decode(state).strip()
def _subElement(parent, tag, text=None, pos=None):
    '''
    Creates a tree subelement of the given tag name and text.
    '''
    element = parent.makeelement(tag, {})
    if text is not None:
        element.text = utils.decode(text)
    if pos is None:
        parent.append(element)
    else:
        parent.insert(pos, element)
    return element
 def _format(self, source, formatter, formatters, kwargs):
     '''
     Formats output data using the given formatters and the source object.
     '''
     if not formatter:
         return ''
     # Sequence formatter
     if isinstance(formatter, (tuple, list)):
         items = []
         formatter, separator, prefix, suffix = formatter
         holders = _placeHoldersNames(formatter)
         if MAPPING_KEY_SYMBOL in holders or MAPPING_VALUE_SYMBOL in holders:
             # Mapping (dict like sequence)
             for key in source:
                 attrs = {
                     MAPPING_KEY_SYMBOL: key,
                     MAPPING_VALUE_SYMBOL: source[key],
                 }
                 attrs.update(kwargs)
                 items.append(_formatData(formatter, attrs,
                                          self._conversionTypes))
         else:
             for item in source:
                 items.append(self._format(item, formatter,
                                           formatters, kwargs))
         if not items:
             return ''
         return prefix + separator.join(items) + suffix
     holders = _placeHoldersNames(formatter)
     if not holders:
         # There is no any named place holder
         return formatter % utils.decode(source)
     attrs = {}
     for name in holders:
         if hasattr(source, name):
             value = getattr(source, name)
             if name in formatters:
                 value = self._format(value, formatters[name],
                                      formatters, kwargs)
             attrs[name] = value
         else:
             # Unknown place holder
             attrs[name] = ''
     attrs.update(kwargs)
     return _formatData(formatter, attrs, self._conversionTypes)
Exemple #9
0
    def hasText(self, device, text, expectedFailure=False):
        '''
        Checks if the represented widget contains the specified text.

        :param device: A device to perform the operation on
        :type device: tadek.connection.device.Device
        :param text: Text to find in the widget
        :type text: string
        :param expectedFailure: It specifies if the widget is not expected to
            contain the text
        :type expectedFailure: boolean
        :return: True if the widget contains the text, False otherwise
        :rtype: boolean
        '''
        widget = self.getWidget(device)
        if widget is None:
            return False
        # Finalize translation and decode string
        text = decode(escape(text, device))
        return delay.text(self._WidgetText(widget, text), expectedFailure)
Exemple #10
0
 def marshal(self, element, value):
     etree.SubElement(element, "path").text = decode(value.path)
     etree.SubElement(element, "mtime").text = decode(value.mtime)
     etree.SubElement(element, "size").text = decode(value.size)
Exemple #11
0
 def marshal(self, element, value):
     element.text = decode(value)
Exemple #12
0
 def getDecoded(*args):
     result = func(*args)
     if result is not None:
         result = decode(result, encoding)
     return result
 def marshal(self, element, value):
     etree.SubElement(element, "path").text = decode(value.path)
     etree.SubElement(element, "mtime").text = decode(value.mtime)
     etree.SubElement(element, "size").text = decode(value.size)
Exemple #14
0
 def __init__(self, msg):
     queue.QueueItem.__init__(self, self.id)
     if isinstance(msg, Exception):
         self.traceback = format_exc()
     Exception.__init__(self, msg)
     self.msg = decode(msg)
Exemple #15
0
 def __init__(self, msg):
     queue.QueueItem.__init__(self, self.id)
     if isinstance(msg, Exception):
         self.traceback = format_exc()
     Exception.__init__(self, msg)
     self.msg = decode(msg)
Exemple #16
0
 def __call__(self, device):
     '''
     Returns a proxied message.
     '''
     return utils.decode(self.message)
Exemple #17
0
 def __call__(self, device):
     '''
     Returns a proxied message.
     '''
     return utils.decode(self.message)
Exemple #18
0
 def marshal(self, element, value):
     element.text = decode(value)
Exemple #19
0
 def getDecoded(*args):
     result = func(*args)
     if result is not None:
         result = decode(result, encoding)
     return result