[accerciser] ipython: Add backwards compatibility with old stable releases of IPython



commit 64b6e0c8f0b9bcb629fdefa54191e0d9f27b4336
Author: Javier Hernández <jhernandez emergya com>
Date:   Tue Mar 18 22:37:14 2014 +0100

    ipython: Add backwards compatibility with old stable releases of IPython
    
    This change makes the IPython plugin work with:
    
      * IPython 2.0.0-dev
      * IPython 1.2.1
      * IPython 0.13.2
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=726332

 plugins/ipython_view.py |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/plugins/ipython_view.py b/plugins/ipython_view.py
index 418b0a5..04f2d53 100755
--- a/plugins/ipython_view.py
+++ b/plugins/ipython_view.py
@@ -19,6 +19,8 @@ from gi.repository import Gdk as gdk
 from gi.repository import GLib
 from gi.repository import Pango
 
+from pkg_resources import parse_version
+
 import re
 import sys
 import os
@@ -70,7 +72,10 @@ class IterableIPShell:
     '''
     io = IPython.utils.io
     if input_func:
-      IPython.terminal.interactiveshell.raw_input_original = input_func
+      if parse_version(IPython.release.version) >= parse_version("1.2.1"):
+        IPython.terminal.interactiveshell.raw_input_original = input_func
+      else:
+        IPython.frontend.terminal.interactiveshell.raw_input_original = input_func
     if cin:
       io.stdin = io.IOStream(cin)
     if cout:
@@ -98,8 +103,12 @@ class IterableIPShell:
 
     # InteractiveShell inherits from SingletonConfigurable, so use instance()
     #
-    self.IP = IPython.terminal.embed.InteractiveShellEmbed.instance(\
-            config=cfg, user_ns=user_ns)
+    if parse_version(IPython.release.version) >= parse_version("1.2.1"):
+      self.IP = IPython.terminal.embed.InteractiveShellEmbed.instance(\
+              config=cfg, user_ns=user_ns)
+    else:
+      self.IP = IPython.frontend.terminal.embed.InteractiveShellEmbed.instance(\
+              config=cfg, user_ns=user_ns)
 
     sys.stdout, sys.stderr = old_stdout, old_stderr
 
@@ -169,7 +178,10 @@ class IterableIPShell:
           self.IP.autoedit_syntax):
           self.IP.edit_syntax_error()
       if not self.iter_more:
-          source_raw = self.IP.input_splitter.raw_reset()
+          if parse_version(IPython.release.version) >= parse_version("2.0.0-dev"):
+            source_raw = self.IP.input_splitter.raw_reset()
+          else:
+            source_raw = self.IP.input_splitter.source_raw_reset()[1]
           self.IP.run_cell(source_raw, store_history=True)
           self.IP.rl_do_indent = False
       else:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]