Robert Kern avatar Robert Kern committed 36a4e2e

BUG: Add compatibility for IPython 0.11.

Comments (0)

Files changed (1)

 
     -r: return the LineProfiler object after it has completed profiling.
     """
-    # Local import to avoid hard dependency.
-    from IPython.genutils import page
-    from IPython.ipstruct import Struct
-    from IPython.ipapi import UsageError
+    # Local imports to avoid hard dependency.
+    from distutils.version import LooseVersion
+    import IPython
+    ipython_version = LooseVersion(IPython.__version__)
+    if ipython_version < '0.11':
+        from IPython.genutils import page
+        from IPython.ipstruct import Struct
+        from IPython.ipapi import UsageError
+    else:
+        from IPython.core.page import page
+        from IPython.utils.ipstruct import Struct
+        from IPython.core.error import UsageError
 
     # Escape quote markers.
     opts_def = Struct(D=[''], T=[''], f=[])
     output = stdout_trap.getvalue()
     output = output.rstrip()
 
-    page(output, screen_lines=self.shell.rc.screen_length)
+    if ipython_version < '0.11':
+        page(output, screen_lines=self.shell.rc.screen_length)
+    else:
+        page(output)
     print message,
 
     dump_file = opts.D[0]
 
     return return_value
 
+
+def load_ipython_extension(ip):
+    """ API for IPython to recognize this module as an IPython extension.
+    """
+    ip.define_magic('lprun', magic_lprun)
+
+
 def load_stats(filename):
     """ Utility function to load a pickled LineStats object from a given
     filename.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.