diff options
author | Michael Lauer <mickey@vanille-media.de> | 2008-02-27 14:19:22 +0000 |
---|---|---|
committer | Michael Lauer <mickey@vanille-media.de> | 2008-02-27 14:19:22 +0000 |
commit | 79f57b121603b1d53f1a58c9dbf0cdc7c136a956 (patch) | |
tree | f81b027dd8a4f93a26811eca0b4920e4dc7b3e34 /packages/python/python-2.5.2/sitecustomize.py | |
parent | c298612723f39dbf17b55ad0deca6baacc81fc3d (diff) |
python 2.5.1 upgrade to 2.5.2
Diffstat (limited to 'packages/python/python-2.5.2/sitecustomize.py')
-rw-r--r-- | packages/python/python-2.5.2/sitecustomize.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/packages/python/python-2.5.2/sitecustomize.py b/packages/python/python-2.5.2/sitecustomize.py new file mode 100644 index 0000000000..4c0ba3f0da --- /dev/null +++ b/packages/python/python-2.5.2/sitecustomize.py @@ -0,0 +1,45 @@ +# OpenEmbedded sitecustomize.py (C) 2002-2008 Michael 'Mickey' Lauer <mlauer@vanille-media.de> +# GPLv2 or later +# Version: 20082201 +# Features: +# * set proper default encoding +# * enable readline completion in the interactive interpreter +# * load command line history on startup +# * save command line history on exit + +import os + +def __exithandler(): + try: + readline.write_history_file( "%s/.python-history" % os.getenv( "HOME", "/tmp" ) ) + except IOError: + pass + +def __registerExitHandler(): + import atexit + atexit.register( __exithandler ) + +def __enableReadlineSupport(): + readline.parse_and_bind("tab: complete") + try: + readline.read_history_file( "%s/.python-history" % os.getenv( "HOME", "/tmp" ) ) + except IOError: + pass + +def __enableDefaultEncoding(): + import sys + try: + sys.setdefaultencoding('utf8') + except LookupError: + pass + +import sys +try: + import rlcompleter, readline +except ImportError: + sys.stderr.write( "Python %s (OpenEmbedded build) sitecustomize.py not active. Please install python-readline.\n" % sys.version.split()[0] ) +else: + __enableDefaultEncoding() + __registerExitHandler() + __enableReadlineSupport() + sys.stderr.write( "Python %s (OpenEmbedded build) sitecustomize.py active.\n" % sys.version.split()[0] ) |