Skip to content

Commit a119f61

Browse files
committed
Check for directory instead of config file
1 parent 3cede9a commit a119f61

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

bpython/wizard.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@
5353
'answers': positive_negative}
5454

5555
filename = os.path.expanduser('~/.bpython/config')
56+
dirname = os.path.expanduser('~/.bpython/')
5657

5758
def is_first_run():
58-
return not os.path.isfile(filename)
59+
return not os.path.isdir(dirname)
5960

6061
def 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():
7678
answer 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

107114
def main():

0 commit comments

Comments
 (0)