Coverage for src/robotide/controller/robotdata.py: 94%
30 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 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.
16import os 1ao
18from .. import robotapi 1ao
21def get_language_from_settings(): 1ao
22 from ..preferences import RideSettings 1aibjklmcndefgh
23 _settings = RideSettings() 1aibjklmcndefgh
24 lang = _settings.get('doc language', '') 1aibjklmcndefgh
25 return lang 1aibjklmcndefgh
28def new_test_case_file(path, tasks=False, lang=None): 1ao
29 lang = lang if lang else get_language_from_settings() 1aibjcndefgh
30 if not isinstance(lang, list): 30 ↛ 32line 30 didn't jump to line 32 because the condition on line 30 was always true1aibjcndefgh
31 lang = [lang] 1aibjcndefgh
32 datafile = robotapi.TestCaseFile(source=path, tasks=tasks, language=lang) 1aibjcndefgh
33 datafile.set_doc_language() 1aibjcndefgh
34 header = 'Tasks' if tasks else 'Test Cases' 1aibjcndefgh
35 datafile.start_table([header], lineno=1, llang=lang) # It is the unique section, so no problem 1aibjcndefgh
36 _create_missing_directories(datafile.directory) 1aibjcndefgh
37 return datafile 1aibjcndefgh
40def new_test_data_directory(path, tasks=False, lang=None): 1ao
41 lang = lang if lang else get_language_from_settings() 1klm
42 if not isinstance(lang, list): 42 ↛ 44line 42 didn't jump to line 44 because the condition on line 42 was always true1klm
43 lang = [lang] 1klm
44 dirname = os.path.dirname(path) 1klm
45 datafile = robotapi.TestDataDirectory(source=dirname, tasks=tasks, language=lang) 1klm
46 datafile.set_doc_language() 1klm
47 datafile.initfile = path 1klm
48 _create_missing_directories(dirname) 1klm
49 return datafile 1klm
52def _create_missing_directories(dirname): 1ao
53 if not os.path.isdir(dirname): 1aibjklmcndefgh
54 os.makedirs(dirname) 1bcdefgh