def add(self, item): """add a Text MessageElement to the existing Text Strings can be passed and are automatically converted in to item.Text() Args: Text text, an element to add to the text Returns: None Raises: Errors are propagated """ if self._is_stringable(item) or self._is_qstring(item): self.items.append(PlainText(item)) elif isinstance(item, MessageElement): self.items.append(item) elif isinstance(item, QPyNullVariant): self.items.append( PlainText( tr('Null (PyQt4.QtCore.QPyNullVariant) found from the data.' ))) else: raise InvalidMessageItemError(item, item.__class__)
def __init__(self, text=None, level=1, **kwargs): """Creates a Heading object Strings can be passed and are automatically converted in to item.Text() We pass the kwargs on to the base class so an exception is raised if invalid keywords were passed. See: http://stackoverflow.com/questions/13124961/ how-to-pass-arguments-efficiently-kwargs-in-python :param text: Text to add to the message as a heading. :type text: basestring :param level: The heading level in html 1-6 in plain text 1-... :type level: int :returns: None """ super(Heading, self).__init__(**kwargs) self.text = None if level < 1: level = 1 self.level = level if text is not None: if self._is_stringable(text) or self._is_qstring(text): self.text = Text(text) elif isinstance(text, Text): self.text = text else: raise InvalidMessageItemError(text, text.__class__)
def add(self, item, header_flag=False, align=None): """Add a Cell to the row :param item: An element to add to the Cells can be list or Cell object. :type item: basestring, QString, list, Cell :param header_flag: Flag indicating it the item is a header or not. :type header_flag: bool :param align: Optional alignment qualifier for all cells in the row. :type align: basestring """ if self._is_stringable(item) or self._is_qstring(item): self.cells.append(Cell(item, header=header_flag, align=align)) elif isinstance(item, Cell): self.cells.append(item) elif isinstance(item, Image): self.cells.append(Cell(item)) elif isinstance(item, list): for i in item: self.cells.append(Cell(i, header=header_flag, align=align)) else: raise InvalidMessageItemError(item, item.__class__)
def add(self, text): """add a Text MessageElement to the existing Text Strings can be passed and are automatically converted in to item.Text() :param text: An element to add to the text. :type text: str """ if self._is_stringable(text) or self._is_qstring(text): self.text.append(PlainText(text)) elif isinstance(text, Text): self.text.append(text) else: raise InvalidMessageItemError(text, text.__class__)
def add(self, item): """Add a row to the table. List can be passed and are automatically converted to Rows :param item: Item an element to add to the rows can be list or Row object :type item: row, list """ if isinstance(item, list): self.rows.append(Row(item)) elif isinstance(item, Row): self.rows.append(item) else: raise InvalidMessageItemError(item, item.__class__)
def add(self, item): """add a row list can be passed and are automatically converted to Rows Args: item an element to add to the rows can be list or Row object Returns: None Raises: Errors are propagated """ if isinstance(item, list): self.rows.append(Row(item)) elif isinstance(item, Row): self.rows.append(item) else: raise InvalidMessageItemError(item, item.__class__)
def add(self, text): """add a Text MessageElement to the existing Text Strings can be passed and are automatically converted in to item.Text() Args: Text text, an element to add to the text Returns: None Raises: Errors are propagated """ if isinstance(text, basestring) or self._is_qstring(text): self.text.append(PlainText(text)) elif isinstance(text, Text): self.text.append(text) else: raise InvalidMessageItemError(text, text.__class__)
def add(self, text): """add a Text MessageElement to the existing Text Strings can be passed and are automatically converted in to item.Text() :param text: An element to add to the text. :type text: str """ if self._is_stringable(text) or self._is_qstring(text): self.text.append(PlainText(text)) elif isinstance(text, Text): self.text.append(text) elif isinstance(text, QPyNullVariant): self.text.append(PlainText( tr('Null (PyQt4.QtCore.QPyNullVariant) found from the data.'))) elif text is None: self.text.append(PlainText( tr('None or Null found from the data.'))) else: raise InvalidMessageItemError(text, text.__class__)
def add(self, item): """add a Cell to the row list can be passed and are automatically converted to Cell Args: item an element to add to the Cells can be list or Cell object Returns: None Raises: Errors are propagated """ if isinstance(item, basestring) or self._is_qstring(item): self.cells.append(Cell(item)) elif isinstance(item, Cell): self.cells.append(item) elif isinstance(item, list): for i in item: self.cells.append(Cell(i)) else: raise InvalidMessageItemError(item, item.__class__)
def add(self, item): """add a Text MessageElement to the existing Text Strings can be passed and are automatically converted in to item.Text() :param item: Text text, an element to add to the text """ if self._is_stringable(item) or self._is_qstring(item): self.items.append(PlainText(item)) elif isinstance(item, MessageElement): self.items.append(item) elif isinstance(item, QPyNullVariant): self.items.append( PlainText( tr('Null (PyQt4.QtCore.QPyNullVariant) found from the data.' ))) elif isinstance(item, tuple) or isinstance(item, list): for i in item: # Recursive call self.add(i) else: raise InvalidMessageItemError(item, item.__class__)