11from .errors import RestartObjectException
22
3+
34class QuitWizard (BaseException ):
45 pass
56
@@ -10,13 +11,16 @@ class QuitWizard(BaseException):
1011def raise_quit (cmd , ctx ):
1112 raise QuitWizard ()
1213
14+
1315def raise_restart (cmd , ctx ):
1416 raise RestartObjectException ()
1517
18+
1619def force_exit (cmd , ctx ):
1720 print ("Exiting..." )
1821 exit ()
1922
23+
2024HELPER_COMMANDS = {
2125 'q' : raise_quit ,
2226 'quit' : raise_quit ,
@@ -46,15 +50,23 @@ def force_exit(cmd, ctx):
4650}
4751
4852
49- _SHORT_EVAL_HELP = ("This parameter can be generated using our custom "
50- "evaluation method. For details, ask for help with "
51- "'?eval'." )
52- _LONG_EVAL_HELP = ("The value for this parameter can be generated using a "
53- "Python-like syntax. You're limited to a single "
54- "expression (generally, a single line of Python) and "
55- "the imports math and numpy (as np). However, this "
56- "allows you to do simple calculations such as:\n "
57- " 100 * np.pi / 180 # 100 degrees in radians" )
53+ _SHORT_EVAL_HELP = ("You can use expression evaluation with this "
54+ "parameter! For details, ask for help with '?eval'." )
55+ _LONG_EVAL_HELP = (
56+ "You can use a Python expression to create the value for this "
57+ "parameter. However, there are a few limitations:\n \n " ,
58+ " * You're limited to a single expression. That basically means a "
59+ "single line of Python, and no control structures like for loops.\n \n "
60+ " * You can't import any libraries. However, math and numpy are "
61+ "included (use numpy as 'np').\n \n "
62+ "The expression evaluator means that you can use simple expressions "
63+ "as input. For example, say you wanted 100 degrees in radians. You "
64+ "could just type\n \n "
65+ " 100 * np.pi / 180\n \n "
66+ "as your input for the parameter."
67+ )
68+
69+
5870class EvalHelperFunc :
5971 """Helper function (input to :class:`.Helper`) for evaluated parameters.
6072
@@ -64,18 +76,19 @@ class EvalHelperFunc:
6476 help string or method that takes arguments and context dict and
6577 results the help string
6678 """
67- def __init__ (self , param_helper , context = None ):
79+ def __init__ (self , param_helper ):
6880 if isinstance (param_helper , str ):
6981 helper = lambda wizard , context : param_helper
7082 else :
7183 helper = param_helper
7284 self .helper = helper
7385
74- def __call__ (self , helpargs , context ):
86+ def __call__ (self , helpargs , context = None ):
7587 if helpargs == "eval" :
7688 return _LONG_EVAL_HELP
7789 return self .helper (helpargs , context ) + "\n \n " + _SHORT_EVAL_HELP
7890
91+
7992class Helper :
8093 """Manage help and command passing on command line.
8194
@@ -121,7 +134,6 @@ def _command_help(self, help_args, context):
121134
122135 return result
123136
124-
125137 def _run_command (self , command , context ):
126138 """Runs a the given command.
127139
0 commit comments