Make printer line width configurable
This commit is contained in:
parent
eb5991468b
commit
4e52c269e3
11
printer.py
11
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}"
|
||||
|
|
Loading…
Reference in New Issue