ui tweaks

This commit is contained in:
cmccabe 2019-11-18 03:04:57 +00:00
parent cddf2cf4a4
commit 4522061d5c
1 changed files with 21 additions and 11 deletions

View File

@ -35,6 +35,7 @@ def build_menu():
if len(linkulator_files) == 0:
print("It looks link there are no links yet. Run 'linkulator -p' to add one.")
exit()
else:
@ -48,6 +49,7 @@ def build_menu():
split_line = line.split('|')
split_line.insert(0,file_owner)
linkulator_lines.append(split_line) ## creating a list of lists
i=1
for idx, line in enumerate(linkulator_lines):
if line[2] == "": # CREATE/INSERT PARENT ID:
@ -62,6 +64,7 @@ def build_menu():
if line[4] not in categories and line[4] != "":
categories.append(line[4])
def print_categories():
print("Current link post categories include: ")
print(categories)
@ -73,16 +76,19 @@ def view_category_contents():
while view_cat not in categories:
view_cat = input("Type a category to view its posts or [Enter] to quit: ")
if view_cat == "":
exit()
graceful_exit()
if view_cat not in categories:
print("Sorry, that category does not exist. Try again, or type \"q\" to quit.")
print("Sorry, that category does not exist. Try again, or hit [Enter] to quit.")
for line in link_data:
if line[4] == view_cat:
print(line)
pid = input("Enter a post ID to see its thread or [Enter] to quit: ")
if pid == "":
exit()
view_thread(pid)
if pid == "": ## HARMLESS BUT UNINTENDED
graceful_exit() ## ABILITY HERE IS THAT USERS
## CAN PUT ANY PID IN, NOT JUST
view_thread(pid) ## FROM WITHIN THIS CATEGORY.
def view_thread(post_id):
@ -93,10 +99,10 @@ def view_thread(post_id):
parent_id = line[1] + "+" + str(line[2])
parent_user = line[1]
parent_timestamp = line[2]
if parent_id == "":
print("Sorry, no such thread found.")
return()
print("Sorry, thread found with that ID.")
return() ## THIS IS NOT A GOOD END POINT. SHOULD ASK USER TO RE-ENTER THEIR CHOICE.
for line in link_data:
if line[1] == parent_user and line[2] == parent_timestamp:
@ -118,8 +124,7 @@ def view_thread(post_id):
elif next_step == "R" or next_step == "r":
reply(parent_user, parent_timestamp, post_id)
else:
print("Thank you for linkulating. Goodbye.")
exit()
graceful_exit()
def post_link():
@ -134,7 +139,8 @@ def post_link():
append_write = 'w' # make a new file if not
with open(filename, append_write) as file:
file.write(timestamp + '||' + link_category + '|' + link_url + '|' + link_title + "\r")
print('Link added. Thank you for linkulating.')
print("Link added!")
graceful_exit()
def reply(owner, tstamp, post_id):
@ -155,6 +161,10 @@ def reply(owner, tstamp, post_id):
view_thread(post_id)
def graceful_exit():
print("Thank you for linkulating. Goodbye.")
exit()
def parse_command():
args = sys.argv[1:]