trepan/inout/input.py
def open(self, inp, opts={}):
        """Use this to set where to read from.

        Set opts['try_lineedit'] if you want this input to interact
        with GNU-like readline library. By default, we will assume to
        try importing and using readline. If readline is not
        importable, line editing is not available whether or not
        opts['try_readline'] is set.

        Set opts['use_raw'] if input should use Python's use_raw(). If
        however 'inp' is a string and opts['use_raw'] is not set, we
        will assume no raw output. Note that an individual readline
        may override the setting.
        """
        get_option = lambda key: Mmisc.option_set(opts, key,
                                                  self.DEFAULT_OPEN_READ_OPTS)
        if (isinstance(inp, io.TextIOWrapper) or
            isinstance(inp, io.StringIO) or
            hasattr(inp, 'isatty') and inp.isatty()):
            self.use_raw = get_option('use_raw')
        elif isinstance(inp, 'string'.__class__):  # FIXME
            if opts is None:
                self.use_raw = False
            else:
                self.use_raw = get_option('use_raw')
                pass
            inp = open(inp, 'r')
        else:
            raise IOError("Invalid input type (%s) for %s" % (type(inp),
                                                                inp))
        self.input     = inp
        self.line_edit = get_option('try_readline') and readline_importable()
        self.closed = False
        return
def open(self, inp, opts={}):
        """Use this to set where to read from.

        Set opts['try_lineedit'] if you want this input to interact
        with GNU-like readline library. By default, we will assume to
        try importing and using readline. If readline is not
        importable, line editing is not available whether or not
        opts['try_readline'] is set.

        Set opts['use_raw'] if input should use Python's use_raw(). If
        however 'inp' is a string and opts['use_raw'] is not set, we
        will assume no raw output. Note that an individual readline
        may override the setting.
        """
        get_option = lambda key: Mmisc.option_set(opts, key,
                                                  self.DEFAULT_OPEN_READ_OPTS)
        if (isinstance(inp, io.TextIOWrapper) or
            isinstance(inp, io.StringIO) or
            hasattr(inp, 'isatty') and inp.isatty()):
            self.use_raw = get_option('use_raw')
        elif isinstance(inp, 'string'.__class__):  # FIXME
            if opts is None:
                self.use_raw = False
            else:
                self.use_raw = get_option('use_raw')
                pass
            inp = open(inp, 'r')
        else:
            raise IOError("Invalid input type (%s) for %s" % (type(inp),
                                                                inp))
        self.input     = inp
        self.line_edit = get_option('try_readline') and readline_importable()
        self.closed = False
        return
Use this to set where to read from.

        Set opts['try_lineedit'] if you want this input to interact
        with GNU-like readline library. By default, we will assume to
        try importing and using readline. If readline is not
        importable, line editing is not available whether or not
        opts['try_readline'] is set.

        Set opts['use_raw'] if input should use Python's use_raw(). If
        however 'inp' is a string and opts['use_raw'] is not set, we
        will assume no raw output. Note that an individual readline
        may override the setting.