]> git.phdru.name Git - dotfiles.git/blobdiff - lib/python/init.py
lib/python/init.py: rename pager.stdin to stdout
[dotfiles.git] / lib / python / init.py
index 359d549e6e2544580e5677efd2640e163da78479..0e33d094ffd5ed895d3ab29214d9ed7002e3bbb5 100644 (file)
@@ -36,22 +36,21 @@ def init():
                 or os.path.expanduser('~/.inputrc')
             readline.read_init_file(initfile)
 
-            histfile = os.path.expanduser('~/.python-history')
+            histfile = os.path.expanduser('~/.python_history')
             try:
                 readline.read_history_file(histfile)
             except IOError:
                 pass  # No such file
 
             def savehist():
-                histfilesize = os.environ.get('HISTFILESIZE') \
-                    or os.environ.get('HISTSIZE')
-                if histfilesize:
+                histsize = os.environ.get('HISTSIZE')
+                if histsize:
                     try:
-                        histfilesize = int(histfilesize)
+                        histsize = int(histsize)
                     except ValueError:
                         pass
                     else:
-                        readline.set_history_length(histfilesize)
+                        readline.set_history_length(histsize)
                 readline.write_history_file(histfile)
 
             import atexit
@@ -136,13 +135,15 @@ def init():
 
     class BasePager:
         def write(self, value):
-            self.stdin.write(value)
+            self.stdout.write(value)
 
         def pprint(self, value):
-            pprint(value, stream=self.stdin)
+            pprint(value,
+                   stream=ColoredFile(self.stdout,
+                                      '\033[1;3%sm' % stdout_color))
 
         def close(self):
-            self.stdin.close()
+            self.stdout.close()
 
     try:
         from subprocess import Popen, PIPE
@@ -150,7 +151,7 @@ def init():
         class Pager(BasePager):
             def __init__(self):
                 self.pipe = Popen(pager, shell=True, stdin=PIPE)
-                self.stdin = self.pipe.stdin
+                self.stdout = self.pipe.stdin
 
             def close(self):
                 BasePager.close(self)
@@ -158,7 +159,7 @@ def init():
     else:
         class Pager(BasePager):
             def __init__(self):
-                self.stdin = os.popen(pager, 'w')
+                self.stdout = os.popen(pager, 'w')
 
     def displayhook(value):
         if value is not None: