Coverage for src/robotide/contrib/testrunner/ArgsParser.py: 94%
27 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 10:40 +0100
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 10:40 +0100
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.
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.
32from robotide.robotapi import LOG_LEVELS
35class ArgsParser:
37 @staticmethod
38 def get_message_log_level(args, default='INFO'):
39 level = ArgsParser._get_arg_value('-L', '--loglevel', 1adlefghbijck
40 args, default)
41 level_list = level.upper().split(':') 1adlefghbijck
42 try: 1adlefghbijck
43 min_level = LOG_LEVELS[level_list[0]] or LOG_LEVELS[default] 1adlefghbijck
44 for i in level_list: 1adlefgbijck
45 min_level = LOG_LEVELS[i] if LOG_LEVELS[i] < min_level else min_level 1adlefgbijck
46 return min_level 1adlefgbijck
47 except KeyError as e: 1h
48 raise TypeError(f"Invalid loglevel: {e}") 1h
50 @staticmethod
51 def get_output_directory(args, default):
52 return ArgsParser._get_arg_value('-d', '--outputdir', 1pno
53 args, default)
55 @staticmethod
56 def _get_arg_value(short_name, full_name, source, default):
57 if short_name in source: 1adlefghbijckpno
58 switch = short_name 1defgijko
59 elif full_name in source: 1alhbcpn
60 switch = full_name 1ahbcn
61 else:
62 return default 1lp
63 i = source.index(switch) 1adefghbijckno
64 if len(source) == i: 64 ↛ 65line 64 didn't jump to line 65 because the condition on line 64 was never true1adefghbijckno
65 return default
66 return source[i + 1] 1adefghbijckno