Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search simplification and python-ization #1

Open
GoogleCodeExporter opened this issue Sep 20, 2015 · 0 comments
Open

search simplification and python-ization #1

GoogleCodeExporter opened this issue Sep 20, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

Hi, I wanted a script to search / list / display tomboy notes and found
your project. It was pretty much what I nedded, plus some neat creation /
edition features.

To have all the details I wanted, I made some work on your code. I'm
attaching a patch to the issue.

Here's a description of the modifications :

- use of "/usr/bin/env python" to suit more environments (where python is
not in /usr/bin but the "env" can tell us where it is)
- class initialization is done in an "__init__" (consctructor) method. In
the main() function, this means that the class instantiation is now "t =
Tommy(noteName, terms, starttdate, enddate)" (kind of) instead of setting
class attributes after instantiation.
- in findMostRecentNote : use of [1:] on allNotes to omit first element
(already processed by function)
- added a use case to the search method : the special note names "*" and
"-" define a search on all notes. so doing "python tommy.py -s - foo" would
search for "foo" in all notes.
- simplified the search method : iterates on notes' lines and searches for
words in arguments. displays the whole line instead of trunking it and
added the line number to the output.
- added colours to the search output. colours use terminal escape
sequences, so it's not the most portable code .. but special cases could be
done for each OS to define colours accordingly..
- turned things around in method displayNote, but the code is the same.
- removed the method argsToString. this is not expected.. to use spaces in
the title, enclose the title in quotes. remaining arguments are put in a
list in the class (and used to search).
- enclosed the call to main() in an if. this removes the bogus call to the
function upon inclusion of the file in some case. in fact it calls it only
when the file is called as the main program. this way, you can import the
file in the python interactive interpreter to do some debugging.

Hope some of those help you ;)

Original issue reported on code.google.com by [email protected] on 14 Sep 2009 at 6:37

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant