Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / lib / python2.4 / curses / __init__.py
CommitLineData
920dae64
AT
1"""curses
2
3The main package for curses support for Python. Normally used by importing
4the package, and perhaps a particular module inside it.
5
6 import curses
7 from curses import textpad
8 curses.initwin()
9 ...
10
11"""
12
13__revision__ = "$Id: __init__.py,v 1.5 2004/07/18 06:14:41 tim_one Exp $"
14
15from _curses import *
16from curses.wrapper import wrapper
17
18# Some constants, most notably the ACS_* ones, are only added to the C
19# _curses module's dictionary after initscr() is called. (Some
20# versions of SGI's curses don't define values for those constants
21# until initscr() has been called.) This wrapper function calls the
22# underlying C initscr(), and then copies the constants from the
23# _curses module to the curses package's dictionary. Don't do 'from
24# curses import *' if you'll be needing the ACS_* constants.
25
26def initscr():
27 import _curses, curses
28 stdscr = _curses.initscr()
29 for key, value in _curses.__dict__.items():
30 if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'):
31 setattr(curses, key, value)
32
33 return stdscr
34
35# This is a similar wrapper for start_color(), which adds the COLORS and
36# COLOR_PAIRS variables which are only available after start_color() is
37# called.
38
39def start_color():
40 import _curses, curses
41 retval = _curses.start_color()
42 if hasattr(_curses, 'COLORS'):
43 curses.COLORS = _curses.COLORS
44 if hasattr(_curses, 'COLOR_PAIRS'):
45 curses.COLOR_PAIRS = _curses.COLOR_PAIRS
46 return retval
47
48# Import Python has_key() implementation if _curses doesn't contain has_key()
49
50try:
51 has_key
52except NameError:
53 from has_key import has_key