class_docstr: Magics related to code management (loading, saving, editing, ...).
docstr: Load code into the current frontend.
  
  Usage:\
    %load [options] source
  
    where source can be a filename, URL, input history range, macro, or
    element in the user namespace
  
  If no arguments are given, loads the history of this session up to this
  point.
  
  Options:
  
    -r <lines>: Specify lines or ranges of lines to load from the source.
    Ranges could be specified as x-y (x..y) or in python-style x:y 
    (x..(y-1)). Both limits x and y can be left blank (meaning the 
    beginning and end of the file, respectively).
  
    -s <symbols>: Specify function or classes to load from python source. 
  
    -y : Don't ask confirmation for loading source above 200 000 characters.
  
    -n : Include the user's namespace when searching for source code.
  
  This magic command can either take a local filename, a URL, an history
  range (see %history) or a macro as argument, it will prompt for
  confirmation before loading source with more than 200 000 characters, unless
  -y flag is passed or if the frontend does not support raw_input::
  
  %load
  %load myscript.py
  %load 7-27
  %load myMacro
  %load http://www.example.com/myscript.py
  %load -r 5-10 myscript.py
  %load -r 10-20,30,40: foo.py
  %load -s MyClass,wonder_function myscript.py
  %load -n MyClass
  %load -n my_module.wonder_function
code: def load(self, arg_s):
      """Load code into the current frontend.
  
          Usage:\\
            %load [options] source
  
            where source can be a filename, URL, input history range, macro, or
            element in the user namespace
  
          If no arguments are given, loads the history of this session up to this
          point.
  
          Options:
  
            -r <lines>: Specify lines or ranges of lines to load from the source.
            Ranges could be specified as x-y (x..y) or in python-style x:y 
            (x..(y-1)). Both limits x and y can be left blank (meaning the 
            beginning and end of the file, respectively).
  
            -s <symbols>: Specify function or classes to load from python source. 
  
            -y : Don't ask confirmation for loading source above 200 000 characters.
  
            -n : Include the user's namespace when searching for source code.
  
          This magic command can either take a local filename, a URL, an history
          range (see %history) or a macro as argument, it will prompt for
          confirmation before loading source with more than 200 000 characters, unless
          -y flag is passed or if the frontend does not support raw_input::
  
          %load
          %load myscript.py
          %load 7-27
          %load myMacro
          %load http://www.example.com/myscript.py
          %load -r 5-10 myscript.py
          %load -r 10-20,30,40: foo.py
          %load -s MyClass,wonder_function myscript.py
          %load -n MyClass
          %load -n my_module.wonder_function
          """
      opts, args = self.parse_options(arg_s, "yns:r:")
      search_ns = "n" in opts
      contents = self.shell.find_user_code(args, search_ns=search_ns)
  
      if "s" in opts:
          try:
              blocks, not_found = extract_symbols(contents, opts["s"])
          except SyntaxError:
              # non python code
              error("Unable to parse the input as valid Python code")
              return
  
          if len(not_found) == 1:
              warn("The symbol `%s` was not found" % not_found[0])
          elif len(not_found) > 1:
              warn(
                  "The symbols %s were not found"
                  % get_text_list(not_found, wrap_item_with="`")
              )
  
          contents = "\n".join(blocks)
  
      if "r" in opts:
          ranges = opts["r"].replace(",", " ")
          lines = contents.split("\n")
          slices = extract_code_ranges(ranges)
          contents = [lines[slice(*slc)] for slc in slices]
          contents = "\n".join(
              strip_initial_indent(chain.from_iterable(contents))
          )
  
      l = len(contents)
  
      # 200 000 is ~ 2500 full 80 character lines
      # so in average, more than 5000 lines
      if l > 200000 and "y" not in opts:
          try:
              ans = self.shell.ask_yes_no(
                  (
                      "The text you're trying to load seems pretty big"
                      " (%d characters). Continue (y/[N]) ?" % l
                  ),
                  default="n",
              )
          except StdinNotImplementedError:
              # assume yes if raw input not implemented
              ans = True
  
          if ans is False:
              print("Operation cancelled.")
              return
  
      contents = "# %load {}\n".format(arg_s) + contents
  
      self.shell.set_next_input(contents, replace=True)
  
imports: import inspect
  import io
  import os
  import re
  import sys
  import ast
  from itertools import chain
  from urllib.request import Request, urlopen
  from urllib.parse import urlencode
  from pathlib import Path
  from IPython.core.error import TryNext, StdinNotImplementedError, UsageError
  from IPython.core.macro import Macro
  from IPython.core.magic import Magics, magics_class, line_magic
  from IPython.core.oinspect import find_file, find_source_lines
  from IPython.core.release import version
  from IPython.testing.skipdoctest import skip_doctest
  from IPython.utils.contexts import preserve_keys
  from IPython.utils.path import get_py_filename
  from warnings import warn
  from logging import error
  from IPython.utils.text import get_text_list
label_desc: Use image node_id 5 for calling the CodeMagics obj's underlying member method code with example usage: obj.load(arg_s) without return types