Make printer line width configurable

This commit is contained in:
Daniel Schulte 2018-03-18 18:56:52 +01:00
parent eb5991468b
commit 4e52c269e3
1 changed files with 7 additions and 4 deletions

View File

@ -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}"