fixed ctrl-c formatting problem; clarified near and long-term todo lists.

This commit is contained in:
cmccabe 2019-11-20 02:49:34 +00:00
parent bc0ec137c0
commit 6d8c6ba67c

View File

@ -6,32 +6,39 @@ import glob
import getpass
import os
from pathlib import Path
import time
from shutil import which
import signal
import sys
import subprocess
import time
## TO DO:
## * AUTOMATED TESTING.
## * ADD SEARCH FUNCTIONALITY (SEARCH FOR TERM IN CATEGORY, TITLE, COMMENT FIELDS).
## * ADD LINK-COUNTS TO CATEGORY MENU.
## TO DO FOR INITIAL "RELEASE":
## * FORMAT OUTPUT INTO USER-FRIENDLY DISPLAY.
## * RATHER THAN GIVING EACH LINK A GLOBAL ID #, CREATE DISPLAY-SPECIFIC ID'S ON
## THE FLY (SUGGESTION FROM SLOUM).
## * ADD REPLY-COUNTS TO THE LIST OF LINKS IN EACH CATEGORY VIEW.
## * MORE VALIDATION OF linkluator.data FILE FORMAT. CURRENTLY JUST CHECKS FOR 4 PIPES.
## * LINKS AND REPLIES NOW SORTED BY DATE -- NEED TO CONFIRM THAT SORTING IS WORKING CORRECTLY.
## * "POST" COMMAND LINE ARG SHOULD TAKE AN OPTIONAL LINK ARGUMENT
## * CAPTURE CTRL-C AND GRACEFULLY EXIT -- WORKING, BUT FORMATTING IS BROKEN. NEEDS FIX.
## * NEED TO VALIDATE THAT LYNX IS INSTALLED, AND DON'T OFFER OPEN-IN-BROWSER IF NOT.
## * UPDATE FILE PERMISSIONS ON ~/.linkulator/linkulator_data ON EACH RUN?
## * WARN USERS IF THEIR ~/.linkulator/linkulator-data FILE IS NOT READABLE BY OTHERS.
## FUTURE, TO DO:
## LINK/REPLIES TREE SHOULD BE A SINGLE DATA STRUCTURE
## * AUTOMATED TESTING
## * LINK/REPLIES TREE SHOULD BE A SINGLE DATA STRUCTURE
## * PAGER FEATURE, E.G. SO A LIST OF 200 LINKS IS SHOWN 20 AT A TIME.
## * SEARCH FUNCTIONALITY (SEARCH FOR TERM IN CATEGORY, TITLE, COMMENT FIELDS).
## * ADD LINK-COUNTS TO CATEGORY MENU.
## * ADD REPLY-COUNTS TO THE LIST OF LINKS IN EACH CATEGORY VIEW.
## * ALLOW USERS TO BOOKMARK LINKS, VIEW LIST OF BOOKMARKED LINKS, AND DISPLAY TOTAL
## NUMBER OF BOOKMARKS FOR A LINK AS A SORT OF "VOTE COUNT"
## * SOME FUNCTIONALITY IS NOT PROPERLY SEGREGATED INTO DISTINCT FUNCTIONS. FIX THIS.
## IN PARTICULAR, view_thread() AND view_category_contents() ARE MIXED TOGETHER.
#######################################################################
username = getpass.getuser()
browser = "lynx"
help_text = """
options: -h or --help; -p or --post; or no option to browse links.
@ -50,6 +57,7 @@ A few important points about Linkulator:
put their username in your ignore file.
* Your ~/.linkulator/linkulator_data file must be readable by others, or nobody else will
see your contributions.
* Linkulator may not work outside of Linux systems.
"""
pipe_count = 4 ## A PROPERLY FORMATED LINE IN linkulator.data HAS EXACTLY FOUR PIPES.
@ -178,7 +186,7 @@ def view_thread(post_id):
if i == 0:
print("(No replies yet. Be the first!)")
next_step = input("Type 'R' to reply, 'B' to view in Lynx, 'M' for main menu, or anything else to quit: ")
next_step = input("Type 'R' to reply, 'B' to view in " + browser + ", 'M' for main menu, or anything else to quit: ")
if next_step == "M" or next_step == "m":
print_categories()
elif next_step =="B" or next_step == "b":
@ -190,12 +198,15 @@ def view_thread(post_id):
def view_link_in_browser(url, post_id):
print("URL = " + url)
if which(browser) is None:
print("Sorry, " + browser + " is not installed on your system. Ask your sysadmin to install it.")
view_thread(post_id)
if url.startswith("gopher://") or url.startswith("https://") or url.startswith("http://"):
subprocess.call(['lynx', url])
else:
print("Sorry, that url doesn't start with gopher://, http:// or https://")
tryAnyway = input("Do you want to try it in Lynx anyway? Y/[N] ")
tryAnyway = input("Do you want to try it in", browser, "anyway? Y/[N] ")
if tryAnyway == "Y" or tryAnyway == "y":
subprocess.call(['lynx', url])
view_thread(post_id)
@ -282,7 +293,7 @@ def search(keyword):
## if next_step...
def graceful_exit():
print("\r\rThank you for linkulating. Goodbye.")
print("\n\nThank you for linkulating. Goodbye.\n")
exit(0)