Robot Framework Integrated Development Environment (RIDE)
message.py
Go to the documentation of this file.
1 # Copyright 2008-2015 Nokia Networks
2 # Copyright 2016- Robot Framework Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 from robotide.lib.robot.utils import html_escape, py2to3, setter
17 
18 from .itemlist import ItemList
19 from .modelobject import ModelObject
20 
21 
22 @py2to3
23 
29  __slots__ = ['message', 'level', 'html', 'timestamp', '_sort_key']
30 
31  def __init__(self, message='', level='INFO', html=False, timestamp=None,
32  parent=None):
33  #: The message content as a string.
34  self.messagemessage = message
35  #: Severity of the message. Either ``TRACE``, ``DEBUG``, ``INFO``,
36  #: ``WARN``, ``ERROR``, or ``FAIL``. The latest one is only used with
37  #: keyword failure messages.
38  self.levellevel = level
39  #: ``True`` if the content is in HTML, ``False`` otherwise.
40  self.htmlhtml = html
41  #: Timestamp in format ``%Y%m%d %H:%M:%S.%f``.
42  self.timestamptimestamp = timestamp
43  self._sort_key_sort_key = -1
44  #: The object this message was triggered by.
45  self.parentparentparent = parent
46 
47  @setter
48  def parent(self, parent):
49  if parent and parent is not getattr(self, 'parent', None):
50  self._sort_key_sort_key = getattr(parent, '_child_sort_key', -1)
51  return parent
52 
53  @property
54 
55  html_message = property
56 
57  def html_message(self):
58  return self.messagemessage if self.htmlhtml else html_escape(self.messagemessage)
59 
60 
61  def visit(self, visitor):
62  visitor.visit_message(self)
63 
64  def __unicode__(self):
65  return self.messagemessage
66 
67 
69  __slots__ = []
70 
71  def __init__(self, message_class=Message, parent=None, messages=None):
72  ItemList.__init__(self, message_class, {'parent': parent}, messages)
73 
74  def __setitem__(self, index, item):
75  old = self[index]
76  ItemList.__setitem__(self, index, item)
77  self[index]._sort_key = old._sort_key
A message created during the test execution.
Definition: message.py:28
def __init__(self, message='', level='INFO', html=False, timestamp=None, parent=None)
Definition: message.py:32
html_message
Returns the message content as HTML.
Definition: message.py:55
def visit(self, visitor)
:mod:Visitor interface <robot.model.visitor> entry-point.
Definition: message.py:61
def __setitem__(self, index, item)
Definition: message.py:74
def __init__(self, message_class=Message, parent=None, messages=None)
Definition: message.py:71
def html_escape(text, linkify=True)
Definition: markuputils.py:40