MCPcopy Index your code
hub / github.com/python/cpython / CustomRun

Class CustomRun

Lib/idlelib/query.py:335–382  ·  view source on GitHub ↗

Get settings for custom run of module. 1. Command line arguments to extend sys.argv. 2. Whether to restart Shell or not.

Source from the content-addressed store, hash-verified

333 return None if name is None or path is None else (name, path)
334
335class CustomRun(Query):
336 """Get settings for custom run of module.
337
338 1. Command line arguments to extend sys.argv.
339 2. Whether to restart Shell or not.
340 """
341 # Used in runscript.run_custom_event
342
343 def __init__(self, parent, title, *, cli_args=[],
344 _htest=False, _utest=False):
345 """cli_args is a list of strings.
346
347 The list is assigned to the default Entry StringVar.
348 The strings are displayed joined by ' ' for display.
349 """
350 message = 'Command Line Arguments for sys.argv:'
351 super().__init__(
352 parent, title, message, text0=cli_args,
353 _htest=_htest, _utest=_utest)
354
355 def create_extra(self):
356 "Add run mode on rows 10-12."
357 frame = self.frame
358 self.restartvar = BooleanVar(self, value=True)
359 restart = Checkbutton(frame, variable=self.restartvar, onvalue=True,
360 offvalue=False, text='Restart shell')
361 self.args_error = Label(frame, text=' ', foreground='red',
362 font=self.error_font)
363
364 restart.grid(column=0, row=10, columnspan=3, padx=5, sticky='w')
365 self.args_error.grid(column=0, row=12, columnspan=3, padx=5,
366 sticky='we')
367
368 def cli_args_ok(self):
369 "Return command line arg list or None if error."
370 cli_string = self.entry.get().strip()
371 try:
372 cli_args = shlex.split(cli_string, posix=True)
373 except ValueError as err:
374 self.showerror(str(err))
375 return None
376 return cli_args
377
378 def entry_ok(self):
379 "Return apparently valid (cli_args, restart) or None."
380 cli_args = self.cli_args_ok()
381 restart = self.restartvar.get()
382 return None if cli_args is None else (cli_args, restart)
383
384
385if __name__ == '__main__':

Callers 1

run_module_eventMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…