Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita583105

Browse files
remove a function
1 parent8e2c0fc commita583105

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

‎bpython/curtsiesfrontend/coderunner.py‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ class SystemExitRequest(RequestFromCodeGreenlet):
4343
classCodeRunner(object):
4444
"""Runs user code in an interpreter.
4545
46-
Running code requests a refresh by calling refresh_and_get_value(), which
46+
Running code requests a refresh by calling
47+
request_from_main_greenlet(force_refresh=True), which
4748
suspends execution of the code and switches back to the main greenlet
4849
4950
After load_code() is called with the source code to be run,
5051
the run_code() method should be called to start running the code.
5152
The running code may request screen refreshes and user input
52-
by callingthe refresh_and_get_value and wait_and_get_value calls
53-
respectively.Whenthese are called, the running source code cedes
53+
by callingrequest_from_main_greenlet.
54+
Whenthis are called, the running source code cedes
5455
control, and the current run_code() method call returns.
5556
5657
The return value of run_code() determines whether the method ought
@@ -154,19 +155,15 @@ def _blocking_run_code(self):
154155
returnSystemExitRequest
155156
returnUnfinishedifunfinishedelseDone
156157

157-
defwait_and_get_value(self):
158+
defrequest_from_main_greenlet(self,force_refresh=False):
158159
"""Return the argument passed in to .run_code(for_code)
159160
160-
Nothing means calls to run_code must be...
161+
Nothing means calls to run_code must be... ???
161162
"""
162-
value=self.main_greenlet.switch(Wait)
163-
ifvalueisSigintHappened:
164-
raiseKeyboardInterrupt()
165-
returnvalue
166-
167-
defrefresh_and_get_value(self):
168-
"""Returns the argument passed in to .run_code(for_code) """
169-
value=self.main_greenlet.switch(Refresh)
163+
ifforce_refresh:
164+
value=self.main_greenlet.switch(Refresh)
165+
else:
166+
value=self.main_greenlet.switch(Wait)
170167
ifvalueisSigintHappened:
171168
raiseKeyboardInterrupt()
172169
returnvalue
@@ -177,7 +174,7 @@ def __init__(self, coderunner, on_write):
177174
self.on_write=on_write
178175
defwrite(self,*args,**kwargs):
179176
self.on_write(*args,**kwargs)
180-
returnself.coderunner.refresh_and_get_value()
177+
returnself.coderunner.request_from_main_greenlet(force_refresh=True)
181178
defwritelines(self,l):
182179
forsinl:
183180
self.write(s)

‎bpython/curtsiesfrontend/repl.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class FakeStdin(object):
4141
def__init__(self,coderunner,repl):
4242
self.coderunner=coderunner
4343
self.repl=repl
44-
self.has_focus=False
44+
self.has_focus=False# whether FakeStdin receives keypress events
4545
self.current_line=''
4646
self.cursor_offset_in_line=0
4747
self.old_num_lines=0
@@ -85,7 +85,7 @@ def add_normal_character(self, e):
8585
defreadline(self):
8686
self.has_focus=True
8787
self.repl.send_to_stdin(self.current_line)
88-
value=self.coderunner.wait_and_get_value()
88+
value=self.coderunner.request_from_main_greenlet()
8989
self.readline_results.append(value)
9090
returnvalue
9191

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp