Robot Framework Integrated Development Environment (RIDE)
CommandArgs.py
Go to the documentation of this file.
1 # Copyright 2010 Orbitz WorldWide
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 # Modified by NSN
16 # Copyright 2010-2012 Nokia Solutions and Networks
17 # Copyright 2013-2015 Nokia Networks
18 # Copyright 2016- Robot Framework Foundation
19 #
20 # Licensed under the Apache License, Version 2.0 (the "License");
21 # you may not use this file except in compliance with the License.
22 # You may obtain a copy of the License at
23 #
24 # http://www.apache.org/licenses/LICENSE-2.0
25 #
26 # Unless required by applicable law or agreed to in writing, software
27 # distributed under the License is distributed on an "AS IS" BASIS,
28 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29 # See the License for the specific language governing permissions and
30 # limitations under the License.
31 
32 # Have to use short options in some methods, because of long option was changed
33 # in RF 2.8 -> 2.9, and we don't necessarily know the installed version.
34 
35 
37  def __init__(self):
38  self._existing_args_existing_args = []
39  self._args_args = []
40  self._without_console_color_without_console_color = False
41  self._tests_to_run_tests_to_run = []
42  self._python_paths_python_paths = []
43  self._console_width_console_width = ''
44  self._output_directory_output_directory = ''
45  self._log_level_log_level = ''
46 
47  def with_existing_args(self, args):
48  self._existing_args_existing_args = args
49  return self
50 
51  def with_python_path(self, paths):
52  self._python_paths_python_paths = paths
53  return self
54 
55  def with_log_level(self, log_level):
56  self._log_level_log_level = log_level
57  return self
58 
59  def with_output_directory(self, output_directory):
60  self._output_directory_output_directory = output_directory
61  return self
62 
63  def with_runnable_tests(self, tests):
64  self._tests_to_run_tests_to_run.clear()
65  for suite, test in tests:
66  self._tests_to_run_tests_to_run += ['--suite', suite, '--test', test]
67  return self
68 
69  def without_console_color(self, without_colors=True):
70  self._without_console_color_without_console_color = without_colors
71  return self
72 
73  def with_console_width(self, console_width):
74  self._console_width_console_width = console_width
75  return self
76 
77  def build(self):
78  if self._existing_args_existing_args:
79  self._args_args.extend(self._existing_args_existing_args)
80 
81  if self._is_necessary_disable_console_color_is_necessary_disable_console_color():
82  self._args_args.extend(['-C', 'off'])
83 
84  if self._is_necessary_add_console_color_is_necessary_add_console_color():
85  from sys import platform
86  if platform.endswith('win32'):
87  self._args_args.extend(['-C', 'ansi'])
88  else:
89  self._args_args.extend(['-C', 'on'])
90 
91  if self._is_necessary_add_console_width_is_necessary_add_console_width():
92  self._args_args.extend(['-W', self._console_width_console_width])
93 
94  if self._is_necessary_add_python_paths_is_necessary_add_python_paths():
95  self._args_args.extend(
96  ['-P', ':'.join(self._python_paths_python_paths)])
97 
98  if self._is_necessary_add_output_dir_is_necessary_add_output_dir():
99  self._args_args.extend(['-d', self._output_directory_output_directory])
100 
101  if self._is_necessary_add_log_level_is_necessary_add_log_level():
102  self._args_args.extend(['-L', self._log_level_log_level])
103 
104  self._args_args.extend(self._tests_to_run_tests_to_run)
105 
106  return self._args_args
107 
109  return self._without_console_color_without_console_color and \
110  '-C' not in self._args_args and \
111  '--consolecolors' not in self._args_args
112 
114  return not self._without_console_color_without_console_color and \
115  '-C' not in self._args_args and \
116  '--consolecolors' not in self._args_args
117 
119  return self._console_width_console_width and \
120  '-W' not in self._args_args and \
121  '--consolewidth' not in self._args_args
122 
124  return self._python_paths_python_paths and \
125  '-P' not in self._args_args and \
126  '--pythonpath' not in self._args_args
127 
129  return self._output_directory_output_directory and \
130  '-d' not in self._args_args and \
131  '--outputdir' not in self._args_args
132 
134  return self._log_level_log_level and \
135  '-L' not in self._args_args and \
136  '--loglevel' not in self._args_args
def with_output_directory(self, output_directory)
Definition: CommandArgs.py:59
def without_console_color(self, without_colors=True)
Definition: CommandArgs.py:69