Show More
@@ -154,34 +154,39 b' class SphinxTransformer(ActivatableTransformer):' | |||
|
154 | 154 | 4: "Conny", |
|
155 | 155 | 5: "Rejne", |
|
156 | 156 | 6: "Sonny"} |
|
157 | default_style = 1 | |
|
158 | 157 | |
|
158 | #Append comments to the menu when displaying it to the user. | |
|
159 | comments = {1: "(default)", | |
|
160 | 6: "(for international documents)"} | |
|
161 | ||
|
162 | return self._prompt_dictionary(styles, menu_comments=comments) | |
|
163 | ||
|
164 | def _prompt_dictionary(self, choices, default_style=1, menu_comments={}): | |
|
165 | ||
|
159 | 166 | # Build the menu that will be displayed to the user with |
|
160 | 167 | # all of the options available. |
|
161 |
|
|
|
162 |
for key, value in |
|
|
163 |
|
|
|
164 |
if key |
|
|
165 |
|
|
|
166 |
|
|
|
167 | style_prompt += " (for international documents)" | |
|
168 | style_prompt += "\n" | |
|
168 | prompt = "" | |
|
169 | for key, value in choices.iteritems(): | |
|
170 | prompt += "%d %s " % (key, value) | |
|
171 | if key in menu_comments: | |
|
172 | prompt += menu_comments[key] | |
|
173 | prompt += "\n" | |
|
169 | 174 | |
|
170 | 175 | # Continue to ask the user for a style until an appropriate |
|
171 | 176 | # one is specified. |
|
172 | 177 | response = -1 |
|
173 |
while ( |
|
|
178 | while (not response in choices): | |
|
174 | 179 | try: |
|
175 |
text_response = self._input( |
|
|
180 | text_response = self._input(prompt) | |
|
176 | 181 | |
|
177 | 182 | # Use default option if no input. |
|
178 | 183 | if len(text_response.strip()) == 0: |
|
179 |
response = |
|
|
184 | response = default_style | |
|
180 | 185 | else: |
|
181 | 186 | response = int(text_response) |
|
182 | 187 | except: |
|
183 |
print("Error: Value |
|
|
184 |
return |
|
|
188 | print("Error: Value is not an available option. 0 selects the default.\n") | |
|
189 | return choices[response] | |
|
185 | 190 | |
|
186 | 191 | def _input(self, prompt_text): |
|
187 | 192 | """ |
General Comments 0
You need to be logged in to leave comments.
Login now