durusmail: durus-users: Patch: add a startup file to 'durus -c'
Patch: add a startup file to 'durus -c'
2005-01-06
2005-01-07
2005-01-07
Patch: add a startup file to 'durus -c'
A.M. Kuchling
2005-01-06
Here's a small patch that causes 'durus -c' to find and execute the
file named by the DURUSSTARTUP env. var (by analogy with
PYTHONSTARTUP).  Possibly the filename should be run through
os.path.expanduser() before opening it.

It would be nice to have a way to add text to the help banner, but I
don't see a tidy way to do that with modifying Python's code.py, so
never mind.

diff -ur Durus-1.3.orig/client.py Durus-1.3/client.py
--- Durus-1.3.orig/client.py    2004-11-16 09:41:05.000000000 -0500
+++ Durus-1.3/client.py 2005-01-06 14:07:01.000000000 -0500
@@ -45,6 +45,10 @@
                  'pp': pprint}
     configure_readline(namespace, os.path.expanduser("~/.durushistory"))
     console = InteractiveConsole(namespace)
+    if os.environ.has_key('DURUSSTARTUP'):
+        filename = os.environ['DURUSSTARTUP']
+        console.runsource('execfile("%s")' % filename)
+
     help = ('    connection -> the connection\n'
             '    root       -> get(0)\n'
             '    get(oid)   -> get an object\n'

--amk

reply