@@ -57,14 +57,19 @@ class GnuplotKernel(ProcessMetaKernel):
5757 _error = False
5858
5959 wrapper : GnuplotREPLWrapper
60+ _bad_prompts : set = set ()
6061
61- def bad_prompt_warning (self ):
62+ def check_prompt (self ):
6263 """
63- Print warning if the prompt is not 'gnuplot>'
64+ Print warning if the prompt looks bad
65+
66+ A bad prompt is one that does not contain the string 'gnuplot>'.
67+ The warning is printed once per bad prompt.
6468 """
65- prompt = cast ("str" , self .wrapper .prompt ). strip ()
66- if not prompt . endswith ( "gnuplot>" ) :
69+ prompt = cast ("str" , self .wrapper .prompt )
70+ if "gnuplot>" not in prompt and prompt not in self . _bad_prompts :
6771 print (f"Warning: The prompt is currently set to '{ prompt } '" )
72+ self ._bad_prompts .add (prompt )
6873
6974 def do_execute_direct (self , code , silent = False ):
7075 # We wrap the real function so that gnuplot_kernel can
@@ -103,7 +108,7 @@ def _do_execute_direct(self, code: str) -> TextOutput | None:
103108 self .display_images ()
104109 self .delete_image_files ()
105110
106- self .bad_prompt_warning ()
111+ self .check_prompt ()
107112
108113 # No empty strings
109114 return result if (result and result .output ) else None
@@ -265,7 +270,7 @@ def get_kernel_help_on(self, info, level=0, none_on_fail=False):
265270 return None if none_on_fail else ""
266271 res = cast ("TextOutput" , self .do_execute_direct ("help %s" % obj ))
267272 text = PROMPT_REMOVE_RE .sub ("" , res .output )
268- self .bad_prompt_warning ()
273+ self .check_prompt ()
269274 return text
270275
271276 def reset_image_counter (self ):
0 commit comments