Add __repr__ methods to most objects`

These are closer to what __str__ should be and will likely change in the
future.
This commit is contained in:
Jan Petykiewicz 2020-05-11 20:31:07 -07:00
commit c236fdb81b
10 changed files with 64 additions and 0 deletions

View file

@ -253,3 +253,10 @@ def get_char_as_polygons(font_path: str,
Shape.unlock(self)
self.mirrored.flags.writeable = True
return self
def __repr__(self) -> str:
rotation = f'{self.rotation*180/pi:g}' if self.rotation != 0 else ''
dose = f' d{self.dose:g}' if self.dose != 1 else ''
locked = ' L' if self.locked else ''
mirrored = ' m{:d}{:d}'.format(*self.mirrored) if self.mirrored.any() else ''
return f'<TextShape "{self.string}" l{self.layer} o{self.offset} h{self.height:g}{rotation}{mirrored}{dose}{locked}>'