|
1 | 1 | #!/usr/bin/env python |
2 | | -# bpython 0.5.3::fancy curses interface to the Python repl::Bob Farrell 2008 |
| 2 | +# bpython 0.5.4::fancy curses interface to the Python repl::Bob Farrell 2008 |
3 | 3 | # |
4 | 4 | # The MIT License |
5 | 5 | # |
@@ -65,6 +65,11 @@ class Dummy( object ): |
65 | 65 | alphas, alphanums, printables, ParseException |
66 | 66 | except ImportError: |
67 | 67 | OPTS.arg_spec = False |
| 68 | +# XXX: This is for later, as the loadrc function checks that it got imported okay. |
| 69 | +# pyparsing will still be in sys.modules even if only part of the import works, so |
| 70 | +# this makes sure only a clean import happens or no import. |
| 71 | + if 'pyparsing' in sys.modules: |
| 72 | + del sys.modules['pyparsing'] |
68 | 73 | else: |
69 | 74 | OPTS.arg_spec = True |
70 | 75 |
|
@@ -218,7 +223,6 @@ def __init__( self, scr, interp, statusbar=None, idle=None): |
218 | 223 | self.s = '' |
219 | 224 | self.list_win_visible = False |
220 | 225 |
|
221 | | - |
222 | 226 | if not OPTS.arg_spec: |
223 | 227 | return |
224 | 228 |
|
@@ -502,6 +506,8 @@ def lsize(): |
502 | 506 | self.scr.touchwin() |
503 | 507 | self.scr.cursyncup() |
504 | 508 | self.scr.noutrefresh() |
| 509 | +# This looks a little odd, but I can't figure a better way to stick the cursor |
| 510 | +# back where it belongs (refreshing the window hides the list_win) |
505 | 511 | self.scr.move( *self.scr.getyx() ) |
506 | 512 | self.list_win.refresh() |
507 | 513 |
|
@@ -1399,10 +1405,15 @@ def loadrc(): |
1399 | 1405 | leaves them as strings and handles hopefully all the sane ways of |
1400 | 1406 | representing a boolean.""" |
1401 | 1407 |
|
1402 | | - if not os.path.isfile( os.path.expanduser( '~/.bpythonrc' ) ): |
| 1408 | + if len(sys.argv) > 2: |
| 1409 | + path = sys.argv[2] |
| 1410 | + else: |
| 1411 | + path = os.path.expanduser( '~/.bpythonrc' ) |
| 1412 | + |
| 1413 | + if not os.path.isfile( path ): |
1403 | 1414 | return |
1404 | 1415 |
|
1405 | | - f = open( os.path.expanduser( '~/.bpythonrc' ) ) |
| 1416 | + f = open( path ) |
1406 | 1417 | parser = shlex.shlex( f ) |
1407 | 1418 |
|
1408 | 1419 | bools = { |
|
0 commit comments