incremented to version 0.7

added filename validator
master
endorphant 2016-05-11 00:10:04 -04:00
parent 30426ab016
commit a82c25840e
4 changed files with 37 additions and 29 deletions

View File

@ -5,6 +5,6 @@
| |___ |___ |___ | [__ |___ |\ | | __ | |\ | |___ | | |___ |___ |___ | [__ |___ |\ | | __ | |\ | |___ |
| | |___ |___ |___ ___] |___ | \| |__] | | \| |___ | | | |___ |___ |___ ___] |___ | \| |__] | | \| |___ |
| | | |
| ver 0.6.5 (fairly unstable) | | ver 0.7.0 (almost stable) |
| ~endorphant/projects/ttbp/changelog.txt | | ~endorphant/projects/ttbp/changelog.txt |
|__________________________________________________________| |__________________________________________________________|

View File

@ -3,6 +3,7 @@
import os import os
import time import time
import subprocess import subprocess
import re
import chatter import chatter
@ -49,7 +50,8 @@ def load_files():
FILES = [] FILES = []
for filename in os.listdir(DATA): for filename in os.listdir(DATA):
filename = os.path.join(DATA, filename) filename = os.path.join(DATA, filename)
if os.path.isfile(filename) and os.path.splitext(filename)[1] == ".txt": #if os.path.isfile(filename) and os.path.splitext(filename)[1] == ".txt":
if os.path.isfile(filename) and valid(filename):
FILES.append(filename) FILES.append(filename)
FILES.sort() FILES.sort()
@ -63,9 +65,6 @@ def write(outurl="default.html"):
for line in HEADER: for line in HEADER:
outfile.write(line) outfile.write(line)
#for line in write_placeholder():
# outfile.write(line)
outfile.write("\n") outfile.write("\n")
for filename in FILES: for filename in FILES:
@ -171,12 +170,31 @@ def meta(entries = FILES):
meta.sort(key = lambda filename:filename[4]) meta.sort(key = lambda filename:filename[4])
meta.reverse() meta.reverse()
return meta return meta
def valid(filename):
# check if the filename is YYYYMMDD.txt
filesplit = os.path.splitext(os.path.basename(filename))
if filesplit[1] != ".txt":
return False
pattern = '^((19|20)\d{2})(0[1-9]|1[0-2])(0[1-9]|1\d|2\d|3[01])$'
if not re.match(pattern, filesplit[0]):
return False
return True
#############
#############
#############
def test(): def test():
load() load()
#for x in FILES:
# print(x)
metaTest = meta() metaTest = meta()

View File

@ -216,9 +216,6 @@ def print_menu(menu):
i += 1 i += 1
def main_menu(): def main_menu():
#os.system("clear")
#print(BANNER)
#redraw()
menuOptions = [ menuOptions = [
"record your feels", "record your feels",
"review your feels", "review your feels",
@ -226,18 +223,11 @@ def main_menu():
"browse global feels", "browse global feels",
"change your settings", "change your settings",
"send some feedback", "send some feedback",
"(wip) see credits"] "see credits"]
#print(SPACER) print("you're at ttbp home. remember, you can always press <ctrl-c> to come back here.\n\n")
#print("you're at ttbp home. remember, you can always press <ctrl-c> to come back here.\n\n") #print("you're at ttbp home.\n\n")
print("you're at ttbp home.\n\n")
print_menu(menuOptions) print_menu(menuOptions)
#print("how are you feeling today? ")
#try:
# choice = raw_input("\ntell me about your feels (or 'quit' to exit): ")
#except KeyboardInterrupt:
# redraw(EJECT)
# return main_menu()
try: try:
choice = raw_input("\ntell me about your feels (or 'quit' to exit): ") choice = raw_input("\ntell me about your feels (or 'quit' to exit): ")
except KeyboardInterrupt: except KeyboardInterrupt:
@ -313,7 +303,8 @@ def view_neighbors(users):
files = os.listdir(os.path.join("/home", user, ".ttbp", "entries")) files = os.listdir(os.path.join("/home", user, ".ttbp", "entries"))
files.sort() files.sort()
for filename in files: for filename in files:
if os.path.splitext(filename)[1] == ".txt" and len(os.path.splitext(filename)[0]) == 8: #if os.path.splitext(filename)[1] == ".txt" and len(os.path.splitext(filename)[0]) == 8:
if core.valid(filename):
count += 1 count += 1
lastfile = os.path.join("/home", user, ".ttbp", "entries", filename) lastfile = os.path.join("/home", user, ".ttbp", "entries", filename)
@ -438,8 +429,9 @@ def view_feed():
filenames = os.listdir(entryDir) filenames = os.listdir(entryDir)
for entry in filenames: for entry in filenames:
### REALLY MAKE A REAL FILENAME VALIDATOR ### REALLY MAKE A REAL FILENAME VALIDATOR
fileSplit = os.path.splitext(entry) #fileSplit = os.path.splitext(entry)
if len(fileSplit[0]) == 8 and fileSplit[1] == ".txt": #if len(fileSplit[0]) == 8 and fileSplit[1] == ".txt":
if core.valid(entry):
feedList.append(os.path.join(entryDir, entry)) feedList.append(os.path.join(entryDir, entry))
metas = core.meta(feedList) metas = core.meta(feedList)

View File

@ -1,18 +1,15 @@
TO-DO: TO-DO:
(goals for stable release) (goals for stable release)
-filename validator
-only count/process entries if filename is
.ttbp/entries/YYMMDD.txt"
-show most recent global entries on html -show most recent global entries on html
-make commenting actually use mail instead of dumping -command line flags:
to a file? -shortcut to most recent feels, writing entry, seeing own entry
-command line flags
-markdown parsing -markdown parsing
-neighbor view takes you to individual entry listing -neighbor view takes you to individual entry listing
(goals for phase two) (goals for phase two)
-make feedback actually use mail instead of dumping to a file
-stylesheet selector -stylesheet selector
-and make a couple more custom stylesheets -and make a couple more custom stylesheets
-replying to entries?? -replying to entries??
@ -29,6 +26,7 @@ CHANGELOG:
ver 0.7 ver 0.7
-fixed program crashing? maybe? -fixed program crashing? maybe?
-added credits -added credits
-added filename validator
ver 0.6.5 ver 0.6.5
-renamed FEELS ENGINE -renamed FEELS ENGINE