Add repr to various classes for nicer debug
This commit is contained in:
27
events.py
27
events.py
@@ -14,6 +14,9 @@ class Event:
|
||||
def __init__(self, at='start'):
|
||||
self._at = timings.Timing(at)
|
||||
|
||||
def __repr__(self):
|
||||
return '{}(at={})'.format(type(self).__name__, self._at)
|
||||
|
||||
def set_timings(self, timings):
|
||||
self._at.set_timings(timings)
|
||||
|
||||
@@ -56,6 +59,9 @@ class Display(Event):
|
||||
self._image.anchor_x = self._image.width // 2
|
||||
self._image.anchor_y = self._image.height // 2
|
||||
|
||||
def __repr__(self):
|
||||
return '{}(at={}, media={}, background={})'.format(type(self).__name__, self._at, self._media, self._background)
|
||||
|
||||
def start(self):
|
||||
self._audiencecontent.new_content(display.DisplayImage(self._image, self._background))
|
||||
print("Started displaying image")
|
||||
@@ -84,6 +90,9 @@ class Playback(Event):
|
||||
self._fadecurve = None
|
||||
self._fadeframe = None
|
||||
|
||||
def __repr__(self):
|
||||
return '{}(at={}, media={}, device={}, tempo={}, beats={}, leadin={}, loop={}, gain={})'.format(type(self).__name__, self._at, self._media, self._device, self._tempo, self._beats, self._leadin, self._loop, self._gain)
|
||||
|
||||
def prepare(self):
|
||||
self._at._timings.register_tempo(self._tempo, self._beats, self._at)
|
||||
|
||||
@@ -143,6 +152,9 @@ class FadeOut(Event):
|
||||
self._duration = duration
|
||||
self._db = db
|
||||
|
||||
def __repr__(self):
|
||||
return '{}(at={}, duration={}, db={})'.format(type(self).__name__, self._at, self._duration, self._db)
|
||||
|
||||
def start(self):
|
||||
print("Fading out")
|
||||
self._eventrunner.notify('fadeout', fadetime=self._duration, db=self._db)
|
||||
@@ -154,6 +166,9 @@ class SetTempo(Event):
|
||||
self._tempo = tempo
|
||||
self._beats = beats
|
||||
|
||||
def __repr__(self):
|
||||
return '{}(at={}, tempo={}, beats={})'.format(type(self).__name__, self._at, self._tempo, self._beats)
|
||||
|
||||
def prepare(self):
|
||||
self._at._timings.register_tempo(self._tempo, self._beats, self._at)
|
||||
|
||||
@@ -168,6 +183,9 @@ class SetMark(Event):
|
||||
super().__init__(*args, **kwargs)
|
||||
self._name = name
|
||||
|
||||
def __repr__(self):
|
||||
return '{}(at={}, name={})'.format(type(self).__name__, self._at, self._name)
|
||||
|
||||
def prepare(self):
|
||||
self._at._timings.register_mark(self._name, self._at)
|
||||
|
||||
@@ -183,6 +201,9 @@ class ButtonMark(Event):
|
||||
self._name = name
|
||||
self._prestart = prestart
|
||||
|
||||
def __repr__(self):
|
||||
return '{}(at={}, name={})'.format(type(self).__name__, self._at, self._name)
|
||||
|
||||
def prepare(self):
|
||||
self._at._timings.register_mark(self._name, None, self._prestart)
|
||||
|
||||
@@ -198,6 +219,9 @@ class Lyrics(Event):
|
||||
self._text = text
|
||||
self._duration = duration
|
||||
|
||||
def __repr__(self):
|
||||
return '{}(at={}, text={}, duration={})'.format(type(self).__name__, self._at, self._text, self._duration)
|
||||
|
||||
def start(self):
|
||||
self._audiencecontent.new_content(display.DisplayLyrics(self._text))
|
||||
print("Started displaying lyrics")
|
||||
@@ -217,6 +241,9 @@ class LightScene(Event):
|
||||
self._scene = scene
|
||||
self._fade = fade
|
||||
|
||||
def __repr__(self):
|
||||
return '{}(at={}, scene={}, fade={})'.format(type(self).__name__, self._at, self._scene, self._fade)
|
||||
|
||||
def start(self):
|
||||
scenes = self._eventrunner.get_config('scenes')
|
||||
scene = scenes[self._scene]
|
||||
|
||||
@@ -178,6 +178,9 @@ class Timing:
|
||||
self._scheduled = False
|
||||
self.parse()
|
||||
|
||||
def __repr__(self):
|
||||
return '{}(at={}, scheduled={}, evaluated={})'.format(type(self).__name__, self._at, self._at_cached != None, self._scheduled)
|
||||
|
||||
def reset(self):
|
||||
self._at_cached = None
|
||||
self._scheduled = False
|
||||
|
||||
Reference in New Issue
Block a user