@@ -27,8 +27,11 @@ def error(self, msg):
2727
2828
2929def version_banner ():
30- return 'bpython version %s on top of Python %s %s' % (
31- __version__ , sys .version .split ()[0 ], sys .executable )
30+ return "bpython version %s on top of Python %s %s" % (
31+ __version__ ,
32+ sys .version .split ()[0 ],
33+ sys .executable ,
34+ )
3235
3336
3437def parse (args , extras = None , ignore_stdin = False ):
@@ -60,24 +63,43 @@ def parse(args, extras=None, ignore_stdin=False):
6063 args = sys .argv [1 :]
6164
6265 parser = RaisingOptionParser (
63- usage = _ ('Usage: %prog [options] [file [args]]\n '
64- 'NOTE: If bpython sees an argument it does '
65- 'not know, execution falls back to the '
66- 'regular Python interpreter.' ))
66+ usage = _ (
67+ "Usage: %prog [options] [file [args]]\n "
68+ "NOTE: If bpython sees an argument it does "
69+ "not know, execution falls back to the "
70+ "regular Python interpreter."
71+ )
72+ )
6773 # This is not sufficient if bpython gains its own -m support
6874 # (instead of falling back to Python itself for that).
6975 # That's probably fixable though, for example by having that
7076 # option swallow all remaining arguments in a callback.
7177 parser .disable_interspersed_args ()
72- parser .add_option ('--config' , default = default_config_path (),
73- help = _ ('Use CONFIG instead of default config file.' ))
74- parser .add_option ('--interactive' , '-i' , action = 'store_true' ,
75- help = _ ('Drop to bpython shell after running file '
76- 'instead of exiting.' ))
77- parser .add_option ('--quiet' , '-q' , action = 'store_true' ,
78- help = _ ("Don't flush the output to stdout." ))
79- parser .add_option ('--version' , '-V' , action = 'store_true' ,
80- help = _ ('Print version and exit.' ))
78+ parser .add_option (
79+ "--config" ,
80+ default = default_config_path (),
81+ help = _ ("Use CONFIG instead of default config file." ),
82+ )
83+ parser .add_option (
84+ "--interactive" ,
85+ "-i" ,
86+ action = "store_true" ,
87+ help = _ (
88+ "Drop to bpython shell after running file " "instead of exiting."
89+ ),
90+ )
91+ parser .add_option (
92+ "--quiet" ,
93+ "-q" ,
94+ action = "store_true" ,
95+ help = _ ("Don't flush the output to stdout." ),
96+ )
97+ parser .add_option (
98+ "--version" ,
99+ "-V" ,
100+ action = "store_true" ,
101+ help = _ ("Print version and exit." ),
102+ )
81103
82104 if extras is not None :
83105 extras_group = OptionGroup (parser , extras [0 ], extras [1 ])
@@ -93,8 +115,10 @@ def parse(args, extras=None, ignore_stdin=False):
93115
94116 if options .version :
95117 print (version_banner ())
96- print ('(C) 2008-2016 Bob Farrell, Andreas Stuehrk, Sebastian Ramacher, Thomas Ballinger, et al. '
97- 'See AUTHORS for detail.' )
118+ print (
119+ "(C) 2008-2016 Bob Farrell, Andreas Stuehrk, Sebastian Ramacher, Thomas Ballinger, et al. "
120+ "See AUTHORS for detail."
121+ )
98122 raise SystemExit
99123
100124 if not ignore_stdin and not (sys .stdin .isatty () and sys .stdout .isatty ()):
@@ -113,13 +137,13 @@ def exec_code(interpreter, args):
113137 Helper to execute code in a given interpreter. args should be a [faked]
114138 sys.argv
115139 """
116- with open (args [0 ], 'r' ) as sourcefile :
140+ with open (args [0 ], "r" ) as sourcefile :
117141 source = sourcefile .read ()
118142 old_argv , sys .argv = sys .argv , args
119143 sys .path .insert (0 , os .path .abspath (os .path .dirname (args [0 ])))
120- mod = imp .new_module (' __console__' )
121- sys .modules [' __console__' ] = mod
144+ mod = imp .new_module (" __console__" )
145+ sys .modules [" __console__" ] = mod
122146 interpreter .locals = mod .__dict__
123- interpreter .locals [' __file__' ] = args [0 ]
124- interpreter .runsource (source , args [0 ], ' exec' )
147+ interpreter .locals [" __file__" ] = args [0 ]
148+ interpreter .runsource (source , args [0 ], " exec" )
125149 sys .argv = old_argv
0 commit comments