12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #!./bin/python3
- import os
- EVENT_UP = "event_up"
- EVENT_DOWN = "event_down"
- EVENT_LEFT = "event_left"
- EVENT_RIGHT = "event_right"
- class HandlerExit(Exception):
- pass
- class BaseHandler:
- def __init__(self, config, display):
- self.display = display
- self.config = config
- def setPlaylistItem(self, item):
- '''
- Called with the selected item.
- '''
- self.item = item
- def update(self):
- '''
- Called when the handler should update the display.
- '''
- raise NotImplementedError("Update not implemented")
- def stop(self):
- '''
- Called when the handler should stop.
- '''
- pass
- def emitEvent(self, event):
- '''
- Called when an event has happened.
- '''
- if event == EVENT_LEFT:
- self.stop()
- raise HandlerExit
- def toDisplayName(self, s):
- s = os.path.splitext(s)[0]
- return s.replace("_", " ").title()
|