Robot Framework Integrated Development Environment (RIDE)
comments.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 is_string
17 
18 
19 class CommentCache():
20 
21  def __init__(self):
22  self._comments_comments = []
23 
24  def add(self, comment):
25  self._comments_comments.append(comment)
26 
27  def consume_with(self, function):
28  print(f"DEBUG: CommentCache enter consume_with {self._comments}")
29  for comment in self._comments_comments:
30  function(comment)
31  self.__init____init__()
32 
33 
34 class Comments():
35 
36  def __init__(self):
37  self._comments_comments = []
38 
39  def add(self, row):
40  if row.comments:
41  self._comments_comments.extend(c.strip() for c in row.comments if c.strip())
42 
43  @property
44  value = property
45 
46  def value(self):
47  return self._comments_comments
48 
49 
50 class Comment():
51 
52  def __init__(self, comment_data):
53  if is_string(comment_data):
54  comment_data = [comment_data] if comment_data else []
55  self._comment_comment = comment_data or []
56  # print(f"DEBUG RFLib Comment input={comment_data} self._comment={self._comment}")
57 
58  def __len__(self):
59  return len(self._comment_comment)
60 
61  def as_list(self):
62  if self._not_commented_not_commented():
63  self._comment_comment[0] = '# ' + self._comment_comment[0]
64  return self._comment_comment
65 
66  def _not_commented(self):
67  return self._comment_comment and self._comment_comment[0] and self._comment_comment[0][0] != '#'
def __init__(self, comment_data)
Definition: comments.py:52