| | 69 | |
| | 70 | # BD-WSB: if pythonrc already defines a (possibly better) completion, |
| | 71 | # this screw up everything, so better to *first* load pythonrc, |
| | 72 | # then test if it's necessary to add completion |
| | 73 | |
| | 74 | # XXX : cf http://code.djangoproject.com/ticket/5936 |
| | 75 | # the plain python shell __would__ use PYTHONSTARTUP and .pythonrc.py |
| | 76 | # so WTF ? |
| | 77 | # if not use_plain: |
| | 78 | pythonrc = os.environ.get("PYTHONSTARTUP") |
| | 79 | if pythonrc and os.path.isfile(pythonrc): |
| | 80 | try: |
| | 81 | #print "loading pythonrc file %s" % pythonrc |
| | 82 | execfile(pythonrc, imported_objects) |
| | 83 | except NameError: |
| | 84 | pass |
| | 85 | # This will import .pythonrc.py as a side-effect |
| | 86 | import user |
| | 87 | |
| | 88 | # XXX |
| 67 | | # We don't have to wrap the following import in a 'try', because |
| 68 | | # we already know 'readline' was imported successfully. |
| 69 | | import rlcompleter |
| 70 | | readline.set_completer(rlcompleter.Completer(imported_objects).complete) |
| 71 | | readline.parse_and_bind("tab:complete") |
| 72 | | |
| 73 | | # We want to honor both $PYTHONSTARTUP and .pythonrc.py, so follow system |
| 74 | | # conventions and get $PYTHONSTARTUP first then import user. |
| 75 | | if not use_plain: |
| 76 | | pythonrc = os.environ.get("PYTHONSTARTUP") |
| 77 | | if pythonrc and os.path.isfile(pythonrc): |
| 78 | | try: |
| 79 | | execfile(pythonrc) |
| 80 | | except NameError: |
| 81 | | pass |
| 82 | | # This will import .pythonrc.py as a side-effect |
| 83 | | import user |
| | 94 | # XXX check if completer is already setup by the pythonrc |
| | 95 | # else add a simple completion |
| | 96 | if not readline.get_completer(): |
| | 97 | # We don't have to wrap the following import in a 'try', because |
| | 98 | # we already know 'readline' was imported successfully. |
| | 99 | import rlcompleter |
| | 100 | readline.set_completer(rlcompleter.Completer(imported_objects).complete) |
| | 101 | readline.parse_and_bind("tab:complete") |
| | 102 | |