Robot Framework Integrated Development Environment (RIDE)
ArgsParser.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 from robotide.robotapi import LOG_LEVELS
33 
34 
35 class ArgsParser:
36 
37  @staticmethod
38  def get_message_log_level(args, default='INFO'):
39  level = ArgsParser._get_arg_value('-L', '--loglevel',
40  args, default)
41  level_list = level.upper().split(':')
42  try:
43  min_level = LOG_LEVELS[level_list[0]] or LOG_LEVELS[default]
44  for i in level_list:
45  min_level = LOG_LEVELS[i] if LOG_LEVELS[i] < min_level else min_level
46  return min_level
47  except KeyError as e:
48  raise TypeError(f"Invalid loglevel: {e}")
49 
50  @staticmethod
51  def get_output_directory(args, default):
52  return ArgsParser._get_arg_value('-d', '--outputdir',
53  args, default)
54 
55  @staticmethod
56  def _get_arg_value(short_name, full_name, source, default):
57  if short_name in source:
58  switch = short_name
59  elif full_name in source:
60  switch = full_name
61  else:
62  return default
63  i = source.index(switch)
64  if len(source) == i:
65  return default
66  return source[i + 1]
def get_message_log_level(args, default='INFO')
Definition: ArgsParser.py:38
def _get_arg_value(short_name, full_name, source, default)
Definition: ArgsParser.py:56