GTG SoC, week 2 — GNOME's Next Top Model

Following on my last week's work mapping the Getting Things GNOME! data model, week 2 of my GSoC experience involved preparing this somewhat-lengthy analysis of how we store tasks in GTG, and how it should change. Of course, it doesn't hold a candle to things like the 168-page iCalendar RFC...of which a good ten percent is devoted to the recurrence specification grammar for VEVENTs and VTODOs.

Needless to say, I recommended we find a more straightforward way of solving this bug. To make you read the actual analysis, I won't give away my other conclusions here!

I have also started a page for user stories to guide future development, and begun moving around large blocks of code to start to tease apart the user-facing and core portions of GTG.

Some questions for the Planet hive mind:

  1. Which is preferred idiom — import sys; sys.exit(1) or raise SystemExit(1)? The latter avoids an import...
  2. Likewise, most modern PyGTK applications include a pygtk.require('2.0') wrapped in a try/except clause. Is this suggested/required in every file that imports gtk, only the lowest level, or only once per application (presumably in the root or top-level UI module)?

1. I prefer import sys;

1. I prefer import sys; sys.exit(1).
oh noes, we're going to import a module! :P sys will probably get imported by some other part of your application anyway.
I would only do this as part of your top-level main function.
e.g.:

def main():
    if something_bad_happened:
        return 1

if __name__ == '__main__':
    import sys
    sys.exit(main())

(you might also like to pass sys.args to main, too)

2. The latter.

Peter Ward (not verified), 7 June 2010 - 6:18pm

Isn't the

Isn't the pygtk.require('2.0') thing something that was used for the Gtk+ 1.x to 2.x transition? I've never bothered with it myself, and can't imagine it serves any useful purpose unless you're running an old distro that still provides a pre-2.x version of PyGtk.

—Simon (not verified), 7 June 2010 - 6:44pm

1. 'raise SystemExit(1)' is

1. 'raise SystemExit(1)' is better, precisely because it doesn't require an import. Both are just as clear and readable.

2. As Simon says the 'pygtk.require's are related to an old transition. No reason to clutter your code with these.

—Osmo Salomaa (not verified), 8 June 2010 - 12:46am

sys.exit() is idiomatic.

sys.exit() is idiomatic.

Marius Gedminas (not verified), 8 June 2010 - 3:27pm

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <b> <blockquote> <cite> <code> <dd> <del> <dl> <dt> <em> <li> <ol> <pre> <ul> <strong> <sub> <sup> <img> <h2> <h3>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

Image CAPTCHA
Enter the characters shown in the image.