summaryrefslogtreecommitdiff
path: root/packages/python/python-2.5.1
diff options
context:
space:
mode:
authorMichael Lauer <mickey@vanille-media.de>2008-01-22 15:42:08 +0000
committerMichael Lauer <mickey@vanille-media.de>2008-01-22 15:42:08 +0000
commitb548b86158d28374bea97dd2e96a490cabcd0bb2 (patch)
treee9ecb77cfbb55e69cfe97b27ba0892587ed429d2 /packages/python/python-2.5.1
parent202cdecd6746fbc98375154ad6e7885690627e05 (diff)
python 2.5.1 ship sitecustomize.py that enables some convenient features when
working with the interactive interpreter: attribute completion and persistent command history
Diffstat (limited to 'packages/python/python-2.5.1')
-rw-r--r--packages/python/python-2.5.1/sitecustomize.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/packages/python/python-2.5.1/sitecustomize.py b/packages/python/python-2.5.1/sitecustomize.py
new file mode 100644
index 0000000000..b5e78d3200
--- /dev/null
+++ b/packages/python/python-2.5.1/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
+
+HISTORY_FILENAME = "/tmp/python-history-file.txt"
+
+def __exithandler():
+ try:
+ readline.write_history_file( HISTORY_FILENAME )
+ except IOError:
+ pass
+
+def __registerExitHandler():
+ import atexit
+ atexit.register( __exithandler )
+
+def __enableReadlineSupport():
+ readline.parse_and_bind("tab: complete")
+ try:
+ readline.read_history_file( "/tmp/python-history-file.txt" )
+ 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] )