Rev 554 | Rev 556 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 554 | Rev 555 | ||
---|---|---|---|
Line 77... | Line 77... | ||
77 | sys.stdout.write('Enter choice number[%d]: ' % defopt) |
77 | sys.stdout.write('Enter choice number[%d]: ' % defopt) |
78 | else: |
78 | else: |
79 | sys.stdout.write('Enter choice number: ') |
79 | sys.stdout.write('Enter choice number: ') |
80 | 80 | ||
81 | def menu(self, text, choices, button, defopt=None): |
81 | def menu(self, text, choices, button, defopt=None): |
- | 82 | menu = [] |
|
- | 83 | for key, descr in choices: |
|
- | 84 | txt = key + (45-len(key))*' ' + ': ' + descr |
|
- | 85 | menu.append((key, txt)) |
|
- | 86 | ||
82 | return self.choice(text, [button] + choices) |
87 | return self.choice(text, [button] + menu) |
83 | 88 | ||
84 | def choice(self, text, choices, defopt=None): |
89 | def choice(self, text, choices, defopt=None): |
85 | self.print_title() |
90 | self.print_title() |
86 | while 1: |
91 | while 1: |
87 | self._print_choice(text, choices, defopt) |
92 | self._print_choice(text, choices, defopt) |
Line 363... | Line 368... | ||
363 | 368 | ||
364 | # Default run will update the configuration file |
369 | # Default run will update the configuration file |
365 | # with newest options |
370 | # with newest options |
366 | if os.path.exists(OUTPUT): |
371 | if os.path.exists(OUTPUT): |
367 | read_defaults(OUTPUT, defaults) |
372 | read_defaults(OUTPUT, defaults) |
368 | 373 | ||
- | 374 | # Dry run only with defaults |
|
369 | varnames = parse_config(INPUT, TMPOUTPUT, DefaultDialog(dlg), defaults) |
375 | varnames = parse_config(INPUT, TMPOUTPUT, DefaultDialog(dlg), defaults) |
370 | # If not in default mode, present selection of all possibilities |
376 | # If not in default mode, present selection of all possibilities |
371 | if not defmode: |
377 | if not defmode: |
372 | defopt = 0 |
378 | defopt = 0 |
373 | while 1: |
379 | while 1: |
- | 380 | # varnames contains variable names that were in the |
|
- | 381 | # last question set |
|
374 | choices = [ (x[1],defaults[x[0]]) for x in varnames ] |
382 | choices = [ (x[1],defaults[x[0]]) for x in varnames ] |
375 | res = dlg.menu('Configuration',choices,('save','Save'),defopt) |
383 | res = dlg.menu('Configuration',choices,('save','Save'),defopt) |
376 | if res == 'save': |
384 | if res == 'save': |
377 | parse_config(INPUT, TMPOUTPUT, DefaultDialog(dlg), defaults) |
385 | parse_config(INPUT, TMPOUTPUT, DefaultDialog(dlg), defaults) |
378 | break |
386 | break |
379 | # transfer description back to varname |
387 | # transfer description back to varname |
380 | for i,(vname,descr) in enumerate(varnames): |
388 | for i,(vname,descr) in enumerate(varnames): |
381 | if res == descr: |
389 | if res == descr: |
382 | defopt = i |
390 | defopt = i |
383 | break |
391 | break |
- | 392 | # Ask the user a simple question, produce output |
|
- | 393 | # as if the user answered all the other questions |
|
- | 394 | # with default answer |
|
384 | varnames = parse_config(INPUT, TMPOUTPUT, dlg, defaults, |
395 | varnames = parse_config(INPUT, TMPOUTPUT, dlg, defaults, |
385 | askonly=varnames[i][0]) |
396 | askonly=varnames[i][0]) |
386 | 397 | ||
387 | 398 | ||
388 | if os.path.exists(OUTPUT): |
399 | if os.path.exists(OUTPUT): |