Coverage for src/robotide/preferences/__init__.py: 87%

34 statements  

« 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. 

15 

16from .configobj.src.configobj import ConfigObj, ConfigObjError, Section, UnreprError 1ab

17from .editor import PreferenceEditor 1ab

18from .editors import GridEditorPreferences, TextEditorPreferences, TestRunnerPreferences 1ab

19from .general import DefaultPreferences 1ab

20from .imports import ImportPreferences 1ab

21from .saving import SavingPreferences 1ab

22from .settings import Settings, initialize_settings, RideSettings 1ab

23 

24import wx 1ab

25 

26 

27class Languages: 1ab

28 names = [('Bulgarian', 'bg-BG', wx.LANGUAGE_BULGARIAN), ('Bosnian', 'bs-BA', wx.LANGUAGE_BOSNIAN), 1ab

29 ('Czech', 'cs-CZ', wx.LANGUAGE_CZECH), ('German', 'de-DE', wx.LANGUAGE_GERMAN), 

30 ('English', 'en-GB', wx.LANGUAGE_ENGLISH), ('Spanish', 'es-ES', wx.LANGUAGE_SPANISH), 

31 ('Finnish', 'fi-FI', wx.LANGUAGE_FINNISH), ('French', 'fr-FR', wx.LANGUAGE_FRENCH), 

32 ('Hindi', 'hi-IN', wx.LANGUAGE_HINDI), ('Italian', 'it-IT', wx.LANGUAGE_ITALIAN), 

33 ('Japanese', 'ja', wx.LANGUAGE_JAPANESE), # Since RF 7.0.1 

34 ('Korean', 'ko-KR', wx.LANGUAGE_KOREAN_KOREA), # Future RF after 7.0.1 

35 ('Dutch', 'nl-NL', wx.LANGUAGE_DUTCH), ('Polish', 'pl-PL', wx.LANGUAGE_POLISH), 

36 ('Portuguese', 'pt-PT', wx.LANGUAGE_PORTUGUESE), 

37 ('Brazilian Portuguese', 'pt-BR', wx.LANGUAGE_PORTUGUESE_BRAZILIAN), 

38 ('Romanian', 'ro-RO', wx.LANGUAGE_ROMANIAN), ('Russian', 'ru-RU', wx.LANGUAGE_RUSSIAN), 

39 ('Swedish', 'sv-SE', wx.LANGUAGE_SWEDISH), ('Thai', 'th-TH', wx.LANGUAGE_THAI), 

40 ('Turkish', 'tr-TR', wx.LANGUAGE_TURKISH), ('Ukrainian', 'uk-UA', wx.LANGUAGE_UKRAINIAN), 

41 ('Vietnamese', 'vi-VN', wx.LANGUAGE_VIETNAMESE), 

42 ('Chinese Simplified', 'zh-CN', wx.LANGUAGE_CHINESE_SIMPLIFIED), 

43 ('Chinese Traditional', 'zh-TW', wx.LANGUAGE_CHINESE_TRADITIONAL)] 

44 

45 

46class Preferences(object): 1ab

47 

48 def __init__(self, settings): 1ab

49 self.settings = settings 1ac

50 self._preference_panels = [] 1ac

51 self._add_builtin_preferences() 1ac

52 self.settings_path = self.settings._default_path 1ac

53 

54 @property 1ab

55 def preference_panels(self): 1ab

56 return self._preference_panels 1c

57 

58 def add(self, preference_ui): 1ab

59 if preference_ui not in self._preference_panels: 59 ↛ exitline 59 didn't return from function 'add' because the condition on line 59 was always true1ac

60 self._preference_panels.append(preference_ui) 1ac

61 

62 def remove(self, panel_class): 1ab

63 if panel_class in self._preference_panels: 

64 self._preference_panels.remove(panel_class) 

65 

66 def _add_builtin_preferences(self): 1ab

67 from ..ui import ExcludePreferences 1ac

68 self.add(DefaultPreferences) 1ac

69 self.add(SavingPreferences) 1ac

70 self.add(ImportPreferences) 1ac

71 self.add(GridEditorPreferences) 1ac

72 self.add(TextEditorPreferences) 1ac

73 self.add(TestRunnerPreferences) 1ac

74 self.add(ExcludePreferences) 1ac