Skip to content

Commit 46bc512

Browse files
Make sample config used as template for new config file
1 parent 4cc3912 commit 46bc512

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

bpython/repl.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,25 +1029,20 @@ def open_in_external_editor(self, filename):
10291029
return False
10301030

10311031
def edit_config(self):
1032-
#TODO put default-config somewhere accessible to this code
1033-
DEFAULT = ("[general]\n"
1034-
"syntax = True\n"
1035-
"[keyboard]\n"
1036-
"pastebin = F8\n"
1037-
"save = C-s\n")
1038-
1039-
open('a.txt', 'w').write(repr(self.config.config_path))
10401032
if not (os.path.isfile(self.config.config_path)):
10411033
if self.interact.confirm(_("Config file does not exist - create new from default? (y/N)")):
10421034
try:
1035+
bpython_dir, script_name = os.path.split(__file__)
1036+
with open(os.path.join(bpython_dir, "sample-config")) as f:
1037+
default_config = f.read()
1038+
10431039
containing_dir = os.path.dirname(os.path.abspath(self.config.config_path))
10441040
if not os.path.exists(containing_dir):
10451041
os.makedirs(containing_dir)
10461042
with open(self.config.config_path, 'w') as f:
1047-
f.write(DEFAULT)
1043+
f.write(default_config)
10481044
except (IOError, OSError) as e:
10491045
self.interact.notify('error creating file: %r' % e)
1050-
raise e
10511046
return False
10521047
else:
10531048
return False
File renamed without changes.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def initialize_options(self):
184184
packages = packages,
185185
data_files = data_files,
186186
package_data = {
187-
'bpython': ['logo.png'],
187+
'bpython': ['logo.png', 'sample-config'],
188188
'bpython.translations': mo_files,
189189
'bpython.test': ['test.config', 'test.theme']
190190
},

0 commit comments

Comments
 (0)