Coverage for src/robotide/ui/progress.py: 65%

32 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 

16import time 1ab

17 

18import wx 1ab

19 

20from .. import context 1ab

21 

22 

23class ProgressObserver(object): 1ab

24 

25 def __init__(self, frame, title, message): 1ab

26 self._progressbar = wx.ProgressDialog(title, message, 

27 maximum=100, parent=frame, 

28 style=wx.PD_ELAPSED_TIME) 

29 

30 def notify(self): 1ab

31 self._progressbar.Pulse() 

32 

33 def finish(self): 1ab

34 try: 

35 self._progressbar.Destroy() 

36 except RuntimeError: 

37 pass 

38 if hasattr(context.LOG, 'report_parsing_errors'): 

39 context.LOG.report_parsing_errors() 

40 

41 def error(self, msg): 1ab

42 self.finish() 

43 if hasattr(context.LOG, 'error'): 

44 context.LOG.error(msg) 

45 

46 

47class LoadProgressObserver(ProgressObserver): 1ab

48 

49 def __init__(self, frame, background=None, foreground=None): 1ab

50 ProgressObserver.__init__(self, frame, 'RIDE', 'Loading the test data') 

51 if background and foreground: 51 ↛ exitline 51 didn't return from function '__init__' because the condition on line 51 was always true

52 self._progressbar.SetBackgroundColour(background) 

53 self._progressbar.SetForegroundColour(foreground) 

54 

55 

56class RenameProgressObserver(ProgressObserver): 1ab

57 

58 def __init__(self, frame, background=None, foreground=None): 1ab

59 ProgressObserver.__init__(self, frame, 'RIDE', 'Renaming') 

60 # self._notification_occured = 0.1 

61 if background and foreground: 

62 self._progressbar.SetBackgroundColour(background) 

63 self._progressbar.SetForegroundColour(foreground) 

64 

65 """ 1ab

66 def notify(self): 

67 if time.time() - self._notification_occured > 0.1: 

68 try: 

69 self._progressbar.Pulse() 

70 except RuntimeError: 

71 pass 

72 self._notification_occured = time.time() 

73 """