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