Skip to content

Commit b0e3a6a

Browse files
committed
imported patch add-banner-kwarg
1 parent 6b3b001 commit b0e3a6a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

bpython/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
__version__ = '0.9.5.2'
2525

2626

27-
def embed(locals_=None, args=['-i', '-q']):
27+
def embed(locals_=None, args=['-i', '-q'], banner=None):
2828
from bpython.cli import main
2929
return main(args, locals_)

bpython/cli.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,8 @@ def curses_wrapper(func, *args, **kwargs):
14991499
curses.endwin()
15001500

15011501

1502-
def main_curses(scr, args, config, interactive=True, locals_=None):
1502+
def main_curses(scr, args, config, interactive=True, locals_=None,
1503+
banner=None):
15031504
"""main function for the curses convenience wrapper
15041505
15051506
Initialise the two main objects: the interpreter
@@ -1553,6 +1554,9 @@ def main_curses(scr, args, config, interactive=True, locals_=None):
15531554
curses.raw(False)
15541555
return repl.getstdout()
15551556

1557+
if banner is not None:
1558+
repl.write(banner)
1559+
repl.write('\n')
15561560
repl.repl()
15571561
if config.hist_length:
15581562
histfilename = os.path.expanduser(config.hist_file)
@@ -1570,7 +1574,7 @@ def main_curses(scr, args, config, interactive=True, locals_=None):
15701574
return repl.getstdout()
15711575

15721576

1573-
def main(args=None, locals_=None):
1577+
def main(args=None, locals_=None, banner=None):
15741578
global stdscr
15751579

15761580
setlocale(LC_ALL, '')
@@ -1584,7 +1588,8 @@ def main(args=None, locals_=None):
15841588

15851589
try:
15861590
o = curses_wrapper(main_curses, exec_args, config,
1587-
options.interactive, locals_)
1591+
options.interactive, locals_,
1592+
banner=banner)
15881593
finally:
15891594
sys.stdin = orig_stdin
15901595
sys.stderr = orig_stderr

0 commit comments

Comments
 (0)