Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # OpenEmbedded sitecustomize.py (C) 2002-2008 Michael 'Mickey' Lauer <mlauer@vanille-media.de> |
| 2 | # GPLv2 or later |
| 3 | # Version: 20081123 |
| 4 | # Features: |
| 5 | # * set proper default encoding |
| 6 | # * enable readline completion in the interactive interpreter |
| 7 | # * load command line history on startup |
| 8 | # * save command line history on exit |
| 9 | |
| 10 | import os |
| 11 | |
| 12 | def __exithandler(): |
| 13 | try: |
| 14 | readline.write_history_file( "%s/.python-history" % os.getenv( "HOME", "/tmp" ) ) |
| 15 | except IOError: |
| 16 | pass |
| 17 | |
| 18 | def __registerExitHandler(): |
| 19 | import atexit |
| 20 | atexit.register( __exithandler ) |
| 21 | |
| 22 | def __enableReadlineSupport(): |
| 23 | readline.set_history_length( 1000 ) |
| 24 | readline.parse_and_bind( "tab: complete" ) |
| 25 | try: |
| 26 | readline.read_history_file( "%s/.python-history" % os.getenv( "HOME", "/tmp" ) ) |
| 27 | except IOError: |
| 28 | pass |
| 29 | |
| 30 | import sys |
| 31 | try: |
| 32 | import rlcompleter, readline |
| 33 | except ImportError: |
| 34 | pass |
| 35 | else: |
| 36 | __registerExitHandler() |
| 37 | __enableReadlineSupport() |