From 4e52c269e3ccdadcc271e6eb38511b7ef0517706 Mon Sep 17 00:00:00 2001 From: Daniel Schulte Date: Sun, 18 Mar 2018 18:56:52 +0100 Subject: [PATCH] Make printer line width configurable --- printer.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/printer.py b/printer.py index 3dc2fa6..f10a75a 100755 --- a/printer.py +++ b/printer.py @@ -20,6 +20,8 @@ import tweepy logging.basicConfig(level=logging.INFO) logger = logging.getLogger("tweet-printer") +printer_line_width = 48 + def load_config(): fn = "config.toml" cfg = {} @@ -64,14 +66,15 @@ def load_config(): def format_header(handle, name, dt, is_rt=None): - space_total = 28 + space_for_datetime = 20 + space = printer_line_width-space_for_datetime header = "" if is_rt is None: is_rt = False if is_rt: header += "RT by " - header += f"@{handle} "[:28] - space_for_name = space_total-len(header)-2 + header += f"@{handle} "[:space] + space_for_name = space-len(header)-2 shortened_by=0 @@ -83,7 +86,7 @@ def format_header(handle, name, dt, is_rt=None): shortened_by = len(name)-shortened_name_len header+=f"({name[:shortened_name_len]}...)" - header = header.ljust(28) + header = header.ljust(space) header += dt.strftime(" %Y-%m-%d %H:%M:%S") #if shortened_by>0: # header += f" name shoretened by {shortened_by}"