code: def master_event(type, master=None):
      '''
      Centralized master event function which will return event type based on event_map
      '''
      event_map = {'connected': '__master_connected',
                   'disconnected': '__master_disconnected',
                   'failback': '__master_failback',
                   'alive': '__master_alive'}
  
      if type == 'alive' and master is not None:
          return '{0}_{1}'.format(event_map.get(type), master)
  
      return event_map.get(type, Nonef master_event(type, master=None):
      '''
      Centralized master event function which will return event type based on event_map
      '''
      event_map = {'connected': '__master_connected',
                   'disconnected': '__master_disconnected',
                   'failback': '__master_failback',
                   'alive': '__master_alive'}
  
      if type == 'alive' and master is not None:
          return '{0}_{1}'.format(event_map.get(type), master)
  
      return event_map.get(type, None)
docs: Centralized master event function which will return event type based on event_map