thermoprint-homework/jobs/base.py

24 lines
606 B
Python

from datetime import datetime
class Job:
def get_name(self):
raise NotImplementedError
def print_body(self, p):
raise NotImplementedError
def run(self, p):
# Shared Header
p.set(align='center', height=2, width=2, bold=True)
p.text(f"{self.get_name()}\n")
p.text("-------------\n")
p.set(align='left', height=1, width=1, bold=False)
now = datetime.now().strftime("%d.%m.%Y %H:%M")
p.text(f"Datum: {now}\n\n")
# Job specific body
self.print_body(p)
# Cut
p.cut()