X Tutup
Skip to content

Commit d5f4c2a

Browse files
committed
Add option to append '.py' to filesnames while saving
1 parent 09c7d92 commit d5f4c2a

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

bpython/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def loadini(struct, configfile):
7272
'pastebin_private': True,
7373
'pastebin_show_url': 'http://bpaste.net/show/$paste_id/',
7474
'pastebin_helper': '',
75+
'save_append_py': False
7576
},
7677
'keyboard': {
7778
'clear_line': 'C-u',
@@ -152,6 +153,7 @@ def loadini(struct, configfile):
152153
methods = config.get('general', 'magic_methods')
153154
struct.magic_methods = [meth.strip() for meth in methods.split(",")]
154155
struct.autocomplete_mode = config.get('general', 'autocomplete_mode')
156+
struct.save_append_py = config.getboolean('general', 'save_append_py')
155157

156158
struct.gtk_font = config.get('gtk', 'font')
157159

bpython/repl.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ def write2file(self):
704704

705705
if fn.startswith('~'):
706706
fn = os.path.expanduser(fn)
707+
if not fn.endswith('.py') and self.config.save_append_py:
708+
fn = fn + '.py'
707709

708710
s = self.formatforfile(self.getstdout())
709711

doc/sphinx/source/configuration-options.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ flush_output
130130
^^^^^^^^^^^^
131131
Whether to flush all output to stdout on exit (default: True).
132132

133+
save_append_py
134+
^^^^^^^^^^^^^^
135+
Whether to append ``.py`` to the filename while saving the input to a file.
136+
137+
.. versionadded:: 0.13
138+
133139
Keyboard
134140
--------
135141
This section refers to the ``[keyboard]`` section in your ``$XDG_CONFIG_HOME/bpython/config``.

0 commit comments

Comments
 (0)
X Tutup