forked from cmccabe/linkulator2
added sort-by-date, and fixed bug in reply function that failed to add timestamp.
This commit is contained in:
parent
8cdb216727
commit
5222b135dc
25
linkulator
25
linkulator
|
@ -11,12 +11,13 @@ import sys
|
|||
import subprocess
|
||||
|
||||
## TO DO:
|
||||
## AUTOMATED TESTING
|
||||
## MORE VALIDATION OF linkluator.data FILE FORMAT. CURRENTLY JUST CHECKS FOR 4 PIPES.
|
||||
## ALL POSTS (LINKS AND REPLIES) SHOULD BE SORTED BY DATE
|
||||
## "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.
|
||||
## * AUTOMATED TESTING
|
||||
## * MORE VALIDATION OF linkluator.data FILE FORMAT. CURRENTLY JUST CHECKS FOR 4 PIPES.
|
||||
## * LINKS AND REPLIES ARE NOW SORTED BY DATE -- BUT 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?
|
||||
|
||||
## FUTURE, TO DO:
|
||||
## LINK/REPLIES TREE SHOULD BE A SINGLE DATA STRUCTURE
|
||||
|
@ -41,6 +42,8 @@ A few important points about Linkulator:
|
|||
to deceive others.
|
||||
* Link/reply threads disappear if the original link poster deletes their post; or if you
|
||||
put their username in your ignore file.
|
||||
* Your ~/.linkulator/linkulator_data file must be readable by others, or nobody else will
|
||||
see your contributions.
|
||||
"""
|
||||
|
||||
pipe_count = 4 ## A PROPERLY FORMATED LINE IN linkulator.data HAS EXACTLY FOUR PIPES.
|
||||
|
@ -96,6 +99,9 @@ def build_menu():
|
|||
linkulator_lines[idx].insert(0,"")
|
||||
link_data = linkulator_lines
|
||||
|
||||
## THIS IS SUPPOSED TO SORT ALL LINKS BY CREATION DATE. NEED TO CONFIRM THAT IT WORKS.
|
||||
link_data.sort(key=lambda x: x[2])
|
||||
|
||||
global categories
|
||||
for line in link_data:
|
||||
if line[4] not in categories and line[4] != "":
|
||||
|
@ -143,8 +149,8 @@ def view_thread(post_id):
|
|||
url = line[5]
|
||||
|
||||
if parent_id == "":
|
||||
print("Sorry, thread found with that ID.")
|
||||
return() ## THIS IS NOT A GOOD END POINT. SHOULD ASK USER TO RE-ENTER THEIR CHOICE.
|
||||
print("Sorry, no thread found with that ID.")
|
||||
print_categories() ## 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:
|
||||
|
@ -236,7 +242,8 @@ def reply(owner, tstamp, post_id):
|
|||
else:
|
||||
append_write = 'w' # make a new file if not
|
||||
with open(filename, append_write) as file:
|
||||
file.write('|' + owner + "+" + tstamp + '|||' + comment + "\r")
|
||||
timestamp = str(time.time())
|
||||
file.write(timestamp + '|' + owner + "+" + tstamp + '|||' + comment + "\r")
|
||||
|
||||
x = input('Reply added. Hit [Enter] to return to thread.')
|
||||
build_menu()
|
||||
|
|
Loading…
Reference in New Issue
Block a user