Show More
@@ -104,16 +104,32 b' class AutoMagics(Magics):' | |||
|
104 | 104 | # all-random (note for auto-testing) |
|
105 | 105 | """ |
|
106 | 106 | |
|
107 | valid_modes = { | |
|
108 | 0: "Off", | |
|
109 | 1: "Smart", | |
|
110 | 2: "Full", | |
|
111 | } | |
|
112 | ||
|
113 | def errorMessage() -> str: | |
|
114 | error = "Valid modes: " | |
|
115 | for k, v in valid_modes.items(): | |
|
116 | error += str(k) + "->" + v + ", " | |
|
117 | error = error[:-2] # remove tailing `, ` after last element | |
|
118 | return error | |
|
119 | ||
|
107 | 120 | if parameter_s: |
|
121 | if not parameter_s in map(str, valid_modes.keys()): | |
|
122 | error(errorMessage()) | |
|
123 | return | |
|
108 | 124 | arg = int(parameter_s) |
|
109 | 125 | else: |
|
110 | 126 | arg = 'toggle' |
|
111 | 127 | |
|
112 |
if not arg in ( |
|
|
113 | error('Valid modes: (0->Off, 1->Smart, 2->Full') | |
|
128 | if not arg in (*list(valid_modes.keys()), "toggle"): | |
|
129 | error(errorMessage()) | |
|
114 | 130 | return |
|
115 | 131 | |
|
116 |
if arg in ( |
|
|
132 | if arg in (valid_modes.keys()): | |
|
117 | 133 | self.shell.autocall = arg |
|
118 | 134 | else: # toggle |
|
119 | 135 | if self.shell.autocall: |
@@ -125,4 +141,4 b' class AutoMagics(Magics):' | |||
|
125 | 141 | except AttributeError: |
|
126 | 142 | self.shell.autocall = self._magic_state.autocall_save = 1 |
|
127 | 143 | |
|
128 |
print("Automatic calling is:", |
|
|
144 | print("Automatic calling is:", list(valid_modes.values())[self.shell.autocall]) |
General Comments 0
You need to be logged in to leave comments.
Login now