Merge pull request 'Finalise new release' (#94) from release into master

Reviewed-on: #94
This commit is contained in:
asdf 2020-07-03 08:00:46 -04:00
commit 495dfff201
2 changed files with 26 additions and 7 deletions

View File

@ -75,7 +75,8 @@ def init():
with defaults if any issues.
"""
USER.datadir.mkdir(mode=0o755, exist_ok=True)
if not USER.datadir.exists():
USER.datadir.mkdir(mode=0o755, exist_ok=True)
if not is_readable(USER.datadir.stat().st_mode):
print(
@ -84,7 +85,8 @@ def init():
)
USER.datadir.chmod(0o755)
USER.datafile.touch(mode=0o644, exist_ok=True)
if not USER.datafile.exists():
USER.datafile.touch(mode=0o644, exist_ok=True)
if not is_readable(USER.datafile.stat().st_mode):
print(

View File

@ -4,7 +4,7 @@
## If this script contains bugs, blame cmccabe.
import getpass
import readline # pylint: disable=unused-import
import readline # pylint: disable=unused-import
import signal
import subprocess
import sys
@ -47,8 +47,24 @@ def print_categories():
def print_category_details(view_cat):
"""produces category detail data, prints it to the console. returns dict
containing an index of threads"""
header = "\n{}\n\n{:>4s} {:<15s}{:<12s} #RESP {:<13s}".format(
style_text(view_cat["name"].upper(), "bold"), "ID#", "DATE", "AUTHOR", "DESC"
columns, _ = get_terminal_size()
maxnamelen = len(max(link_data, key=lambda x: len(x[1]))[1])
namelen = max(maxnamelen, 6) # minimum field width is 6
desclen = (
columns - 18 - namelen - 9 - 1
) # length of available space for the description field.
# The terminal width, minus the width of ID and Date fields and padding,
# minus the max name length, minus Resp field and padding width, minus the
# unread mark width
header = "\n{}\n\n {:>3s} {:>10s} {:<{namelen}s} {:<5} {:<s}".format(
style_text(view_cat["name"].upper(), "bold"),
"ID#",
"DATE",
"AUTHOR",
"#RESP",
"DESC",
namelen=namelen,
)
out = ""
link_count = 0
@ -63,10 +79,11 @@ def print_category_details(view_cat):
new_replies = len(
[line for line in replies if line[2] >= config.USER.lastlogin]
)
desc = textwrap.shorten(line[6], width=desclen, placeholder="...")
newmarker = "*" if new_replies or line[2] >= config.USER.lastlogin else ""
_dt = datetime.fromtimestamp(float(line[2])).strftime("%Y-%m-%d")
out += "{:4d} {:<15s}{:<12s} [{:3d}] {:s}{}\n".format(
link_count, _dt, line[1], len(replies), line[6], newmarker
out += " {:3d} {:>10s} {:<{namelen}s} [{:3d}] {:s}{}\n".format(
link_count, _dt, line[1], len(replies), desc, newmarker, namelen=namelen
)
if len(out) > 0: