[enh] journal list correctly list available journals

This commit is contained in:
Laurent Peuch 2016-06-24 07:42:50 +02:00
parent 0668c7e350
commit a6d89f8ea1

View file

@ -50,7 +50,23 @@ def journals_list():
if not os.path.exists(JOURNALS_PATH): if not os.path.exists(JOURNALS_PATH):
return {} return {}
return {} result = {}
for category in os.listdir(JOURNALS_PATH):
result[category] = []
for journal in filter(lambda x: x.endswith(".journal"), os.listdir(os.path.join(JOURNALS_PATH, category))):
journal = journal[:-len(".journal")]
journal = journal.split("_")
journal_datetime = datetime.strptime(" ".join(journal[-2:]), "%Y-%m-%d %H-%M-%S")
result[category].append({
"started_at": journal_datetime,
"name": " ".join(journal[:-2]),
})
result[category] = list(reversed(sorted(result[category], key=lambda x: x["started_at"])))
return result
class Journal(object): class Journal(object):