Skip to content

Commit 97aea7a

Browse files
committed
A working, though hackish version
1 parent 030c834 commit 97aea7a

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

bpython/wizard.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,28 @@
2525

2626
import os
2727
import sys
28+
from ConfigParser import ConfigParser
2829

2930
# questions asked by the wizard (keys are the config values, followed by text
3031
# and answers and defaults
3132
positive_answers = ('Y', 'y', 'yes', 'ja',)
3233
negative_answers = ('N', 'n', 'no', 'nein',)
3334

34-
questions = {'arg_spec': {'question': 'Do you want to show the argspec (y/n): ',
35+
# FIXME find a better abstraction/representation
36+
questions = {'auto_display_list': {'question': 'Do you want to show the autocomplete list as you type (y/n):',
37+
'answers': {positive_answers: 'True',
38+
negative_answers: 'False'},
39+
'section': 'general'
40+
},
41+
'arg_spec': {'question': 'Do you want to show the argspec (y/n):',
3542
'answers': {positive_answers: 'True',
36-
negative_answers: 'False'}
43+
negative_answers: 'False'},
44+
'section': 'general'
3745
},
38-
'syntax': {'question': 'Do you want syntax highlighting as you type (y/n): ',
46+
'syntax': {'question': 'Do you want syntax highlighting as you type (y/n):',
3947
'answers': {positive_answers: 'True',
40-
negative_answers: 'False'}
48+
negative_answers: 'False'},
49+
'section': 'general'
4150
}
4251
}
4352

@@ -70,7 +79,11 @@ def run_wizard():
7079
if answer.lower() in negative_answers:
7180
create_empty_file()
7281
else:
73-
answers = {}
82+
config = ConfigParser()
83+
84+
# FIXME hacks
85+
config.add_section('general')
86+
config.add_section('keyboard')
7487

7588
# Ask the questions
7689
print
@@ -80,16 +93,16 @@ def run_wizard():
8093
answer = raw_input()
8194

8295
if answer in positive_answers:
83-
answers[config_value] = question['answers'][positive_answers]
96+
config.set(['section'], config_value, question['answers'][positive_answers])
8497
break
8598
elif answer in negative_answers:
86-
answers[config_value] = question['answers'][negative_answers]
99+
config.set(question['section'], config_value, question['answers'][negative_answers])
87100
break
88101
else:
89102
print
90103
print 'I couldn\'t understand the answer you provided, please try again'
91104

92-
print answers
105+
config.write(open(filename, 'w'))
93106

94107
def main():
95108
if is_first_run():

0 commit comments

Comments
 (0)