Formatted with black

This commit is contained in:
asdf 2021-07-25 13:20:51 +10:00
parent e500167d27
commit 6c84b12062
3 changed files with 22 additions and 7 deletions

View File

@ -255,7 +255,10 @@ class LinkData:
new_replies = [i for i in replies if i[2] >= config.USER.lastlogin] new_replies = [i for i in replies if i[2] >= config.USER.lastlogin]
if replies: if replies:
last_modified_timestamp = str( last_modified_timestamp = str(
max(float(timestamp), max([float(i[2]) for i in replies if i[2]])) max(
float(timestamp),
max([float(i[2]) for i in replies if i[2]]),
)
) )
else: else:
last_modified_timestamp = timestamp last_modified_timestamp = timestamp

View File

@ -75,10 +75,18 @@ def print_category_details(view_cat):
link_count += 1 link_count += 1
thread_index[link_count] = link["postid"] thread_index[link_count] = link["postid"]
desc = textwrap.shorten(link["description"], width=desclen, placeholder="...") desc = textwrap.shorten(link["description"], width=desclen, placeholder="...")
newmarker = "*" if link["last_modified_timestamp"] >= config.USER.lastlogin else "" newmarker = (
"*" if link["last_modified_timestamp"] >= config.USER.lastlogin else ""
)
_dt = datetime.fromtimestamp(float(link["link_timestamp"])).strftime("%Y-%m-%d") _dt = datetime.fromtimestamp(float(link["link_timestamp"])).strftime("%Y-%m-%d")
out += " {:3d} {:>10s} {:<{namelen}s} [{:3d}] {:s}{}\n".format( out += " {:3d} {:>10s} {:<{namelen}s} [{:3d}] {:s}{}\n".format(
link_count, _dt, link["link_author"], link["reply_count"], desc, newmarker, namelen=namelen link_count,
_dt,
link["link_author"],
link["reply_count"],
desc,
newmarker,
namelen=namelen,
) )
if len(out) > 0: if len(out) > 0:
@ -268,15 +276,17 @@ def is_valid_input(entry: str) -> bool:
return False return False
return True return True
def is_correct_category(entry: str) -> bool: def is_correct_category(entry: str) -> bool:
"""Make sure the user purposefully created a new category and not by """Make sure the user purposefully created a new category and not by
accident (mistyped, tried to use category number instead of name)""" accident (mistyped, tried to use category number instead of name)"""
if entry not in [ record["name"] for record in categories ]: if entry not in [record["name"] for record in categories]:
question = "Do you want to create a new category '{}'? Y/[N]".format(entry) question = "Do you want to create a new category '{}'? Y/[N]".format(entry)
answer = input(question).lower().strip() answer = input(question).lower().strip()
return answer != "" and answer[0] == "y" return answer != "" and answer[0] == "y"
return True return True
def get_input(item: str) -> str: def get_input(item: str) -> str:
"""Get user input with the specified prompt, validate and return it, or """Get user input with the specified prompt, validate and return it, or
break if invalid""" break if invalid"""
@ -398,7 +408,9 @@ def menu_view_category_details(cat_index):
menu_view_thread_details(post_id) menu_view_thread_details(post_id)
except (KeyError, ValueError): except (KeyError, ValueError):
# Catch a Post ID that is not in the thread list or is not a number # Catch a Post ID that is not in the thread list or is not a number
print("{}\n\n".format(style_text("Invalid category ID/entry", False, "bold"))) print(
"{}\n\n".format(style_text("Invalid category ID/entry", False, "bold"))
)
def menu_view_thread_details(post_id): def menu_view_thread_details(post_id):
@ -450,7 +462,7 @@ def style_text(text: str, is_input: bool, *args) -> str:
# (ctrl+shift+esc+E to enable evil mode.) # (ctrl+shift+esc+E to enable evil mode.)
"inverse": "\033[7m", # Make fg and bg color swap "inverse": "\033[7m", # Make fg and bg color swap
"rl_left_fix": "\001" if is_input else "", "rl_left_fix": "\001" if is_input else "",
"rl_right_fix": "\002" if is_input else "" "rl_right_fix": "\002" if is_input else "",
} }
out = "" out = ""
for arg in args: for arg in args:

View File

@ -18,5 +18,5 @@ setup(
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: POSIX", "Operating System :: POSIX",
], ],
python_requires='>=3.6', python_requires=">=3.6",
) )