Exemple #1
0
    def __init__(self, term=None, fd=-1):

        # Type check for term
        if term is not None and not isinstance(term, BASESTRING):
            raise TypeError('term must be a string or None, not %s' %
                            type(term).__name__)

        # Type check and default handling for fd
        if fd == -1:
            try:
                self.stream_fd = sys.stdout.fileno()
            except (AttributeError, TypeError, io.UnsupportedOperation):
                self.stream_fd = None
        elif not isinstance(fd, int):
            raise TypeError('fd must be an integer, not %s' %
                            type(fd).__name__)
        else:
            self.stream_fd = fd

        # Try to dynamically determine terminal type
        if term is None:
            term = get_term(self.stream_fd)

        try:
            self.terminfo = importlib.import_module('jinxed.terminfo.%s' %
                                                    term.replace('-', '_'))
        except ImportError:
            raise error('Could not find terminal %s' % term)
Exemple #2
0
def tigetflag(capname):
    """
    Reimplementation of curses.tigetflag()
    """

    if TERM is None:
        raise error('Must call setupterm() first')
    return TERM.tigetflag(capname)
def tigetstr(capname):
    """
    Reimplementation of :py:func:`curses.tigetstr`
    """

    if TERM is None:
        raise error('Must call setupterm() first')
    return TERM.tigetstr(capname)