[GTK/MERGE] refactor __init__ to remove duplication.

John Arbash Meinel john at arbash-meinel.com
Sun Apr 8 14:23:06 BST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robert Collins wrote:
> Btw, whats the policy for who can push to the gtk trunk? Should I push
> straight there?
> 
> -Rob
> 
> 
> ------------------------------------------------------------------------
> 
> # Bazaar revision bundle v0.9
> #
> # message:
> #   Minor refactoring of __init__ to have less duplication.
> # committer: Robert Collins <robertc at robertcollins.net>
> # date: Fri 2007-03-23 20:48:53.913000107 +1100
> 
> === modified file __init__.py
> --- __init__.py
> +++ __init__.py
> @@ -89,49 +89,49 @@
>      bzrlib.ui.ui_factory = GtkUIFactory()
>  
>  
> -class cmd_gbranch(Command):
> +class GTKCommand(Command):
> +    """Abstract class providing GTK specific run commands."""
> +
> +    def open_display(self):
> +        pygtk = import_pygtk()
> +        try:
> +            import gtk
> +        except RuntimeError, e:
> +            if str(e) == "could not open display":
> +                raise NoDisplayError
> +        set_ui_factory()

^- Don't you need to re-raise the RuntimeError if it is something else?

try:
  import gtk
except RuntimeError, e:
  if str(e) == "could not open display":
    raise NoDisplayError
  raise
...

And it would seem reasonable to do "str(e).lower()" in case they change
the formatting. But that isn't a big deal.

John
=:->


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGGOy6JdeBCYSNAAMRAqViAKCATmBoNeJYepiXhItJCIH+uSzDiACePaDR
etRRC6BmKWUCAYPPhmLJ8v8=
=kNCd
-----END PGP SIGNATURE-----



More information about the bazaar mailing list