recommendations for personal journaling application

D

Donnie Rhodes

Hi. I've been sort of standing back on the sidelines reading this list
for awhile, and this is my first posting. So a little about myself and
my skill level. My name is Bryan. I'm new to Python and have very
little experience. I've gone through a few of the tutorials. I
understand the different data-types, basic syntax, functions and
function definition, basic iteration, and calling from modules.

I might be getting ahead of myself, but I think the best way for me to
learn things is by having a goal and working towards it. My goal is to
create a personal command line journaling application. I would like to
store all the entries in one file, have them searchable by keywords,
date, topic, etc... I think I would like to use "/*" type commands. For
instance, you call the application from a terminal window and start
with a generic prompt. You would type '/ne /t "topic"' to begin a new
entry and assign the topic; '/d' to set a date. You should be able to
use the slash commands while editing as well. For instance while
writing in an entry you could isolate a phrase or word with /k "phrase
to be marked as searchable keyword" / to mark the enclosed text as a
searchable keyword/keyphrase.

So what I'm interested in is how this would work. Is this 'event
driven' in nature? Would I define the bulk of these slash commands in a
function and then call it at the end of the script? What would be a
good module to look at for the text processing and searching aspects?
Anyways, I'm not sure how you would create a program that would
"listen" for commands and then parse them accordingly. I think for
starters I will sketch out on paper the slash commands I need, and try
to break apart the general operations into pseudo code. How would you
all approach this?

Thank you all and I hope I'm not biting off too much at once...
 
K

Karsten W.

Hi!

Donnie said:
So what I'm interested in is how this would work. Is this 'event
driven' in nature? Would I define the bulk of these slash commands in a
function and then call it at the end of the script? What would be a
good module to look at for the text processing and searching aspects?

For implementing the commandline interface, have a look at the getopt
module.

If you store your data in a flat text file, you might use string.find()
or the re module to do the searching. The re module can search case
insensitive and is more versatile.

But maybe you want let your script create some SQL statements and use
the pysqlite module to store and search the data.

Kind regards,
Karsten.
 
A

Ant

Donnie Rhodes wrote:
....
Thank you all and I hope I'm not biting off too much at once...

Not if you break it up into pieces. Look at the things you want to do,
and in the first instance, create a function for each. Then you can
start to fill in the blanks, and if neccessary ask back here for advice
on each bit.

For example, your skeleton script may look something like:

def main():
options = get_options()
text = fetch_body()
entry_data = parse_text(text, options)
store_entry(entry_data)

def get_options():
pass

def fetch_body()
pass
....

if __name__ == "__main__":
main()

Ideas for the various parts:

get_options() - getopt or optparse modules (the former is simpler to
start with);

fetch_body() - just read from sys.stdin (that way you can also pipe
text into it from a file or the output from another program as well);

parse_text() - regexes could suffice if the flags and what they are
supposed to do is simple, otherwise a grammar parsing module could be
useful such as pyparsing (http://pyparsing.wikispaces.com/);

store_entry() - I'd probably go with XML for the storage format if you
really want to store the entries in a single text file, as you can
structure it well, there are good tools in python 2.5 for building xml
(xml.etree.ElementTree) and you could implement a fast search engine
using SAX. Otherwise a database may be a better option (e.g. sqlite).
 
T

Terry Reedy

keyword/keyphrase.
So what I'm interested in is how this would work. Is this 'event
driven' in nature?

I would call it line-input driven -- a special case that is easier to
program.
Would I define the bulk of these slash commands in a
function and then call it at the end of the script?

I would consider a dict mapping command letters to functions.

tjr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,201
Latest member
KourtneyBe

Latest Threads

Top