[PATCH] color: add support for terminfo-based attributes and color
Danek Duvall
duvall at comfychair.org
Thu Aug 27 13:50:45 UTC 2009
Martin Geisler wrote:
> > +# Mapping from effect name to terminfo attribute name or color number
> > +_terminfo_params = {'none': (True, 'sgr0'),
> > + 'black': (False, curses.COLOR_BLACK),
>
> It looks to me like this will break if curses is not imported? You
> should probably set 'curses = None' if the import fails, and then test
> on curses before using it here and in the rest of the code.
Good point.
I also realized that the demandimport thing is messing with my ability to
know whether curses imported properly. The try/except ImportError is
useless, and "curses" is not in sys.modules, nor is its presence in
globals() indicative of a successful load.
So what's the right way to test for successful load? Trigger the load by
accessing a member and catch ImportError there?
Danek
More information about the Mercurial-devel
mailing list