Robot Framework
configurer.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 robot import model
17 from robot.utils import is_string, secs_to_timestamp, timestamp_to_secs
18 
19 
20 
32 
33  def __init__(self, remove_keywords=None, log_level=None, start_time=None,
34  end_time=None, **base_config):
35  model.SuiteConfigurer.__init__(self, **base_config)
36  self.remove_keywordsremove_keywords = self._get_remove_keywords_get_remove_keywords(remove_keywords)
37  self.log_levellog_level = log_level
38  self.start_timestart_time = self._get_time_get_time(start_time)
39  self.end_timeend_time = self._get_time_get_time(end_time)
40 
41  def _get_remove_keywords(self, value):
42  if value is None:
43  return []
44  if is_string(value):
45  return [value]
46  return value
47 
48  def _get_time(self, timestamp):
49  if not timestamp:
50  return None
51  try:
52  secs = timestamp_to_secs(timestamp, seps=' :.-_')
53  except ValueError:
54  return None
55  return secs_to_timestamp(secs, millis=True)
56 
57  def visit_suite(self, suite):
58  model.SuiteConfigurer.visit_suite(self, suite)
59  self._remove_keywords_remove_keywords(suite)
60  self._set_times_set_times(suite)
61  suite.filter_messages(self.log_levellog_level)
62 
63  def _remove_keywords(self, suite):
64  for how in self.remove_keywordsremove_keywords:
65  suite.remove_keywords(how)
66 
67  def _set_times(self, suite):
68  if self.start_timestart_time:
69  suite.starttime = self.start_timestart_time
70  if self.end_timeend_time:
71  suite.endtime = self.end_timeend_time
def __init__(self, remove_keywords=None, log_level=None, start_time=None, end_time=None, **base_config)
Definition: configurer.py:34
def visit_suite(self, suite)
Implements traversing through suites.
Definition: configurer.py:57
def secs_to_timestamp(secs, seps=None, millis=False)
Definition: robottime.py:348
def timestamp_to_secs(timestamp, seps=None)
Definition: robottime.py:339