@@ -79,7 +79,6 @@ def toggle_editmode(_):
7979 self .input = self .session .input
8080 self .line_edit = True
8181 self .closed = False
82- self .use_raw = False
8382 else :
8483 self .session = None
8584 self .input = inp or sys .stdin
@@ -94,31 +93,20 @@ def close(self):
9493 return
9594
9695 def use_history (self ):
97- return self . use_raw or self . session
96+ return True
9897
9998 def open (self , inp , opts = {}):
10099 """Use this to set where to read from.
101100
102- Set opts['use_raw'] if input should use Python's use_raw(). If
103- however 'inp' is a string and opts['use_raw'] is not set, we
104- will assume no raw output. Note that an individual readline
105- may override the setting.
106101 """
107- if (
102+ if isinstance (inp , "string" .__class__ ): # FIXME
103+ inp = open (inp , "r" )
104+ elif not (
108105 isinstance (inp , io .TextIOWrapper )
109106 or isinstance (inp , io .StringIO )
110107 or hasattr (inp , "isatty" )
111108 and inp .isatty ()
112109 ):
113- self .use_raw = opts and opts .get ("use_raw" , False )
114- elif isinstance (inp , "string" .__class__ ): # FIXME
115- if opts is None :
116- self .use_raw = False
117- else :
118- self .use_raw = opts .get ("use_raw" , False )
119- pass
120- inp = open (inp , "r" )
121- else :
122110 raise IOError ("Invalid input type (%s) for %s" % (type (inp ), inp ))
123111 self .input = inp
124112 self .line_edit = bool (opts and opts .get ("readline" ))
@@ -143,24 +131,13 @@ def readline(self, use_raw=None, prompt=""):
143131 line = self .session .prompt (html_prompt , style = Style .from_dict ({"" : "" }))
144132 return line .rstrip ("\n " )
145133
146- if use_raw is None :
147- use_raw = self .use_raw
148- pass
149- if use_raw :
150- try :
151- inp = input (prompt )
152- # import pdb; pdb.set_trace()
153- return inp
154- except ValueError :
155- raise EOFError
156- pass
157-
158- else :
159- line = self .input .readline ()
160- if not line :
161- raise EOFError
162- return line .rstrip ("\n " )
163- pass
134+ try :
135+ inp = input (prompt )
136+ # import pdb; pdb.set_trace()
137+ return inp
138+ except ValueError :
139+ raise EOFError
140+ return
164141
165142 pass
166143
0 commit comments