This assumes you already have a text file with some moment entries in it. See ‘Make Moments‘ if not.
I’ll base these examples off of the sample context, available in the moments source:
moments/sample/
Most interactions with the library involve loading a collection of moments from a log file into a Journal object:
from moments.journal import Journal
j = Journal("sample/todo.txt")
print len(j.entries())
# 18!
If you want to load all moment log files contained in a directory, use load_journal():
from moments.path import load_journal
j = load_journal("sample/")
print len(j.entries())
# 18
load_journal() will scan for text (.txt) files that start with a moment entry (*[date]). It also looks for duplicate entries (based on the timestamp and entry data) and will try to merge tags automatically.
From here there are many operations you can perform on a moments.journal.Journal. See the Mindstream package and check the ‘scripts’ directory for examples.