
import wx

from robotide import context


class LoadProgressObserver(object):

    def __init__(self, frame):
        self._progressbar = wx.ProgressDialog('RIDE', 'Loading the test data',
                                              maximum=100, parent=frame,
                                              style=wx.PD_ELAPSED_TIME)

    def notify(self):
        self._progressbar.Pulse()

    def finish(self):
        self._progressbar.Destroy()
        context.LOG.report_parsing_errors()

    def error(self, msg):
        self.finish()
        context.LOG.error(msg)


import wx
import time

from robotide import context


class ProgressObserver(object):

    def __init__(self, frame, title, message):
        self._progressbar = wx.ProgressDialog(title, message,
                                              maximum=100, parent=frame,
                                              style=wx.PD_ELAPSED_TIME)

    def notify(self):
        self._progressbar.Pulse()

    def finish(self):
        self._progressbar.Destroy()
        context.LOG.report_parsing_errors()

    def error(self, msg):
        self.finish()
        context.LOG.error(msg)


class LoadProgressObserver(ProgressObserver):

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


class RenameProgressObserver(ProgressObserver):

    def __init__(self, frame):
        ProgressObserver.__init__(self, frame, 'RIDE', 'Renaming')
        self._notification_occured = 0

    def notify(self):
        if time.time() - self._notification_occured > 0.1:
            self._progressbar.Pulse()
            self._notification_occured = time.time()

Introduce base class and ProgressObserver for renaming occurences.
progess: Introduce base class and ProgressObserver for renaming occurences.

  
  import wx
+ import time
  
  from robotide import context
  
  
- class LoadProgressObserver(object):
+ class ProgressObserver(object):
  
-     def __init__(self, frame):
+     def __init__(self, frame, title, message):
-         self._progressbar = wx.ProgressDialog('RIDE', 'Loading the test data',
+         self._progressbar = wx.ProgressDialog(title, message,
                                                maximum=100, parent=frame,
                                                style=wx.PD_ELAPSED_TIME)
  
      def notify(self):
          self._progressbar.Pulse()
  
      def finish(self):
          self._progressbar.Destroy()
          context.LOG.report_parsing_errors()
  
      def error(self, msg):
          self.finish()
          context.LOG.error(msg)
  
+ 
+ class LoadProgressObserver(ProgressObserver):
+ 
+     def __init__(self, frame):
+         ProgressObserver.__init__(self, frame, 'RIDE', 'Loading the test data')
+ 
+ 
+ class RenameProgressObserver(ProgressObserver):
+ 
+     def __init__(self, frame):
+         ProgressObserver.__init__(self, frame, 'RIDE', 'Renaming')
+         self._notification_occured = 0
+ 
+     def notify(self):
+         if time.time() - self._notification_occured > 0.1:
+             self._progressbar.Pulse()
+             self._notification_occured = time.time()
+ 
Introduce base class and ProgressObserver for renaming occurences.
## Code Before:

import wx

from robotide import context


class LoadProgressObserver(object):

    def __init__(self, frame):
        self._progressbar = wx.ProgressDialog('RIDE', 'Loading the test data',
                                              maximum=100, parent=frame,
                                              style=wx.PD_ELAPSED_TIME)

    def notify(self):
        self._progressbar.Pulse()

    def finish(self):
        self._progressbar.Destroy()
        context.LOG.report_parsing_errors()

    def error(self, msg):
        self.finish()
        context.LOG.error(msg)

## Instruction:
Introduce base class and ProgressObserver for renaming occurences.
## Code After:

import wx
import time

from robotide import context


class ProgressObserver(object):

    def __init__(self, frame, title, message):
        self._progressbar = wx.ProgressDialog(title, message,
                                              maximum=100, parent=frame,
                                              style=wx.PD_ELAPSED_TIME)

    def notify(self):
        self._progressbar.Pulse()

    def finish(self):
        self._progressbar.Destroy()
        context.LOG.report_parsing_errors()

    def error(self, msg):
        self.finish()
        context.LOG.error(msg)


class LoadProgressObserver(ProgressObserver):

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


class RenameProgressObserver(ProgressObserver):

    def __init__(self, frame):
        ProgressObserver.__init__(self, frame, 'RIDE', 'Renaming')
        self._notification_occured = 0

    def notify(self):
        if time.time() - self._notification_occured > 0.1:
            self._progressbar.Pulse()
            self._notification_occured = time.time()
