forked from endorphant/ttbp
adding entry meta generator
parent
0cbb1836be
commit
4622af4683
34
bin/core.py
34
bin/core.py
|
@ -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)
|
||||
|
|
10
bin/ttbp.py
10
bin/ttbp.py
|
@ -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
|
||||
#####
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue