diff options
| author | smosker <[email protected]> | 2022-02-10 16:48:21 +0300 |
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:48:21 +0300 |
| commit | dd14d17a747a9c259858faf2fcc3ea6b92df4e15 (patch) | |
| tree | f332cd81782832c17c48d8c3b4511924cd9e47fd /contrib/python/ipython/py2/IPython/core/magics | |
| parent | b637e2fa3213638fbabe52c15dad14c8237945ac (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/ipython/py2/IPython/core/magics')
3 files changed, 46 insertions, 46 deletions
diff --git a/contrib/python/ipython/py2/IPython/core/magics/basic.py b/contrib/python/ipython/py2/IPython/core/magics/basic.py index ca69e2e698a..304bf4228cf 100644 --- a/contrib/python/ipython/py2/IPython/core/magics/basic.py +++ b/contrib/python/ipython/py2/IPython/core/magics/basic.py @@ -3,7 +3,7 @@ from __future__ import print_function from __future__ import absolute_import -import argparse +import argparse import io import sys from pprint import pformat @@ -288,14 +288,14 @@ Currently the magic system has the following functions:""", @line_magic def profile(self, parameter_s=''): - """DEPRECATED since IPython 2.0. - - Raise `UsageError`. To profile code use the :magic:`prun` magic. - + """DEPRECATED since IPython 2.0. + Raise `UsageError`. To profile code use the :magic:`prun` magic. + + See Also -------- - prun : run code using the Python profiler (:magic:`prun`) + prun : run code using the Python profiler (:magic:`prun`) """ warn("%profile is now deprecated. Please use get_ipython().profile instead.") from IPython.core.application import BaseIPythonApplication @@ -551,7 +551,7 @@ Currently the magic system has the following functions:""", @magic_arguments.magic_arguments() @magic_arguments.argument( '-e', '--export', action='store_true', default=False, - help=argparse.SUPPRESS + help=argparse.SUPPRESS ) @magic_arguments.argument( 'filename', type=unicode_type, @@ -562,24 +562,24 @@ Currently the magic system has the following functions:""", """Export and convert IPython notebooks. This function can export the current IPython history to a notebook file. - For example, to export the history to "foo.ipynb" do "%notebook foo.ipynb". - - The -e or --export flag is deprecated in IPython 5.2, and will be - removed in the future. + For example, to export the history to "foo.ipynb" do "%notebook foo.ipynb". + + The -e or --export flag is deprecated in IPython 5.2, and will be + removed in the future. """ args = magic_arguments.parse_argstring(self.notebook, s) from nbformat import write, v4 - - cells = [] - hist = list(self.shell.history_manager.get_range()) - if(len(hist)<=1): - raise ValueError('History is empty, cannot export') - for session, execution_count, source in hist[:-1]: - cells.append(v4.new_code_cell( - execution_count=execution_count, - source=source - )) - nb = v4.new_notebook(cells=cells) - with io.open(args.filename, 'w', encoding='utf-8') as f: - write(nb, f, version=4) + + cells = [] + hist = list(self.shell.history_manager.get_range()) + if(len(hist)<=1): + raise ValueError('History is empty, cannot export') + for session, execution_count, source in hist[:-1]: + cells.append(v4.new_code_cell( + execution_count=execution_count, + source=source + )) + nb = v4.new_notebook(cells=cells) + with io.open(args.filename, 'w', encoding='utf-8') as f: + write(nb, f, version=4) diff --git a/contrib/python/ipython/py2/IPython/core/magics/execution.py b/contrib/python/ipython/py2/IPython/core/magics/execution.py index 3734b0cdae0..73f7581cb66 100644 --- a/contrib/python/ipython/py2/IPython/core/magics/execution.py +++ b/contrib/python/ipython/py2/IPython/core/magics/execution.py @@ -437,7 +437,7 @@ python-profiler package from non-free.""") def _debug_exec(self, code, breakpoint): if breakpoint: - (filename, bp_line) = breakpoint.rsplit(':', 1) + (filename, bp_line) = breakpoint.rsplit(':', 1) bp_line = int(bp_line) else: (filename, bp_line) = (None, None) @@ -806,17 +806,17 @@ python-profiler package from non-free.""") self.shell.InteractiveTB.pdb = self.shell.InteractiveTB.debugger_cls() deb = self.shell.InteractiveTB.pdb - # deb.checkline() fails if deb.curframe exists but is None; it can - # handle it not existing. https://github.com/ipython/ipython/issues/10028 - if hasattr(deb, 'curframe'): - del deb.curframe - + # deb.checkline() fails if deb.curframe exists but is None; it can + # handle it not existing. https://github.com/ipython/ipython/issues/10028 + if hasattr(deb, 'curframe'): + del deb.curframe + # reset Breakpoint state, which is moronically kept # in a class bdb.Breakpoint.next = 1 bdb.Breakpoint.bplist = {} bdb.Breakpoint.bpbynumber = [None] - deb.clear_all_breaks() + deb.clear_all_breaks() if bp_line is not None: # Set an initial breakpoint to stop execution maxtries = 10 @@ -1013,13 +1013,13 @@ python-profiler package from non-free.""") ast_setup = self.shell.transform_ast(ast_setup) ast_stmt = self.shell.transform_ast(ast_stmt) - # Check that these compile to valid Python code *outside* the timer func - # Invalid code may become valid when put inside the function & loop, - # which messes up error messages. - # https://github.com/ipython/ipython/issues/10636 - self.shell.compile(ast_setup, "<magic-timeit-setup>", "exec") - self.shell.compile(ast_stmt, "<magic-timeit-stmt>", "exec") - + # Check that these compile to valid Python code *outside* the timer func + # Invalid code may become valid when put inside the function & loop, + # which messes up error messages. + # https://github.com/ipython/ipython/issues/10636 + self.shell.compile(ast_setup, "<magic-timeit-setup>", "exec") + self.shell.compile(ast_stmt, "<magic-timeit-stmt>", "exec") + # This codestring is taken from timeit.template - we fill it in as an # AST, so that we can apply our AST transformations to the user code # without affecting the timing code. diff --git a/contrib/python/ipython/py2/IPython/core/magics/script.py b/contrib/python/ipython/py2/IPython/core/magics/script.py index 3fbddc38a80..22e6c465798 100644 --- a/contrib/python/ipython/py2/IPython/core/magics/script.py +++ b/contrib/python/ipython/py2/IPython/core/magics/script.py @@ -246,8 +246,8 @@ class ScriptMagics(Magics): def kill_bg_processes(self): """Kill all BG processes which are still running.""" - if not self.bg_processes: - return + if not self.bg_processes: + return for p in self.bg_processes: if p.poll() is None: try: @@ -255,9 +255,9 @@ class ScriptMagics(Magics): except: pass time.sleep(0.1) - self._gc_bg_processes() - if not self.bg_processes: - return + self._gc_bg_processes() + if not self.bg_processes: + return for p in self.bg_processes: if p.poll() is None: try: @@ -265,9 +265,9 @@ class ScriptMagics(Magics): except: pass time.sleep(0.1) - self._gc_bg_processes() - if not self.bg_processes: - return + self._gc_bg_processes() + if not self.bg_processes: + return for p in self.bg_processes: if p.poll() is None: try: |
