adding entry meta generator

master
endorphant 2016-05-04 11:00:28 -04:00
parent 0cbb1836be
commit 4622af4683
3 changed files with 45 additions and 2 deletions

View File

@ -2,6 +2,7 @@
import os
import time
import subprocess
import chatter
@ -145,3 +146,36 @@ def parse_date(file):
date = [rawdate[0:4], rawdate[4:6], rawdate[6:]]
return date
def meta(entries = FILES):
# takes a list of filenames and returns:
# [0] absolute path
# [1] ctime
# [2] wc -w
# [3] timestamp "DD month YYYY at HH:MM"
# [4] entry date YYYY-MM-DD
# sorted in reverse date order by [4]
meta = []
for filename in FILES:
ctime = os.path.getctime(filename)
wc = subprocess.check_output(["wc","-w",filename]).split()[0]
timestamp = time.strftime("%Y-%m-%d %H:%M", time.localtime(ctime))
date = "-".join(parse_date(filename))
meta.append([filename, ctime, wc, timestamp, date])
meta.sort(key = lambda filename:filename[4])
meta.reverse()
return meta
def test():
load()
#for x in FILES:
# print(x)
metaTest = meta()
for x in metaTest:
print(x)

View File

@ -332,11 +332,17 @@ def view_neighbors(users):
return
def view_entries():
def view_entries(entryDir=DATA):
entries = []
raw_input("\n\npress <ctrl-c> to go back home.\n\n")
for entry in core.meta():
entries.append(entry[4]+" ("+p.no("word", entry[2])+") ")
print_menu(entries)
choice = raw_input("\n\npick an entry to read, or press <ctrl-c> to go back home.\n\n")
redraw()
return
#####

View File

@ -11,6 +11,9 @@ TO-DO:
function is view_entries() on ttbp.py
-browse other blogs
-show most recent global entries
(goals for phase two)
-stylesheet selector
-and make a couple more custom stylesheets