nicer linewrap algo for the small printer

workspace
Brendan Howell 4 years ago
parent 4f3b0478dc
commit a6b74ad065

@ -94,7 +94,7 @@ class LogPrinter(logging.Handler):
out_ep=self.printer["outep"]) out_ep=self.printer["outep"])
msg = self.format(record) msg = self.format(record)
#text = textwrap.fill(msg, width=self.printer["textwidth"]) #text = textwrap.fill(msg, width=self.printer["textwidth"])
spliter_regex = r'.{1,' + self.printer["textwidth"] + '}(?:\s+|$)' spliter_regex = r'.{1,' + str(self.printer["textwidth"]) + '}(?:\s+|$)'
out_text = "\r\n".join(line.strip() for line in out_text = "\r\n".join(line.strip() for line in
re.findall(spliter_regex, text)) re.findall(spliter_regex, text))
out_text += "\r\n" * 4 out_text += "\r\n" * 4
@ -446,7 +446,7 @@ class Bureau(object):
""" """
prn = self._get_small_printer() prn = self._get_small_printer()
spliter_regex = r'.{1,' + self.printer["textwidth"] + '}(?:\s+|$)' spliter_regex = r'.{1,' + str(self.printer["textwidth"]) + '}(?:\s+|$)'
out_text = "\r\n".join(line.strip() for line in out_text = "\r\n".join(line.strip() for line in
re.findall(splitter_regex, text)) re.findall(splitter_regex, text))

Loading…
Cancel
Save