File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 5353 'answers' : positive_negative }
5454
5555filename = os .path .expanduser ('~/.bpython/config' )
56+ dirname = os .path .expanduser ('~/.bpython/' )
5657
5758def is_first_run ():
58- return not os .path .isfile ( filename )
59+ return not os .path .isdir ( dirname )
5960
6061def create_empty_file ():
62+ os .mkdir (dirname )
6163 f = open (filename , 'w' )
6264 f .write ('' )
6365 f .close ()
@@ -76,14 +78,18 @@ def run_wizard():
7678answer no to the following question.
7779"""
7880
81+ # Always create an empty file to prevent the wizard from running the next
82+ # time
83+ create_empty_file ()
84+
7985 answer = raw_input ('Do you want to run the wizard: ' )
8086
81- if answer .lower () in negative_answers :
82- create_empty_file ()
83- else :
87+ # If the answer is positive, start wizard
88+ if answer .lower () in positive_answers :
8489 config = ConfigParser ()
8590
8691 for section_name , section in questions .iteritems ():
92+ # Create sections on the fly
8793 config .add_section (section_name )
8894
8995 print
@@ -102,6 +108,7 @@ def run_wizard():
102108 print
103109 print "I couldn't understand the answer you provided, please try again"
104110
111+ # Write the config file
105112 config .write (open (filename , 'w' ))
106113
107114def main ():
You can’t perform that action at this time.
0 commit comments