parameters: (name)
docstring: only support `import ...`, no `from ... import` or `import ... as`
docstring_summary: only support `import ...`, no `from ... import` or `import ... as`
docstring_tokens: only support import ... no from ... import or import ... as
function: def _minimal_package_import_check(name):
      """
      only support `import ...`, no `from ... import` or `import ... as`
      """
      with _ImportLockContext():
          _ret = sys.modules.get(name, None)
  
      if _ret is not None:
          return _ret
  
      try:
          if six.PY2:
              # imp importing submodule is too tricky
              # moulde and pkg naming should follow pep8
              if not all([x.isalnum() or x in "._" for x in name]):
                  raise ValueError("invalid module name")
              exec("import %s as __mpkg_ret" % name)
              # import a.b.c will register name as a.b.c
              return __mpkg_ret  # pylint: disable=undefined-variable  # noqa
          else:
              return importlib.import_module(name)
      except ImportError as e:
          if USE_MINIMAL:
              # e.g., tesorflow.compat.v1 should report tensorflow
              if "." in name:
                  name = name.split(".")[0]
  
              # trim the local version started by '+', if there's any
              pos = __version__.rfind("+")
  
              if pos != -1:
                  version = __version__[:pos]
              else:
                  version = __version__
  
              # append more information from Import error
              emsg = str(e)
              emsg = (
                  "{}.\nThis is a minimal package for SFrame only, without {} pinned"
                  " as a dependency. You can try install all required packages by installing"
                  " the full package. For example:\n"
                  "pip install --force-reinstall turicreate=={}\n"
              ).format(emsg, name, version)
  
              if six.PY2:
                  # __str__ and __repr__ uses `args`.
                  # only change the first element of args tuple
                  args = list(e.args)
                  if args:
                      args[0] = emsg
                  else:
                      args = (emsg,)
                  e.args = tuple(args)
                  e.message = emsg
              else:
                  e.msg = emsg
  
          raise e
function_tokens: def _minimal_package_import_check ( name ) : with _ImportLockContext ( ) : _ret = sys . modules . get ( name , None ) if _ret is not None : return _ret try : if six . PY2 : # imp importing submodule is too tricky # moulde and pkg naming should follow pep8 if not all ( [ x . isalnum ( ) or x in "._" for x in name ] ) : raise ValueError ( "invalid module name" ) exec ( "import %s as __mpkg_ret" % name ) # import a.b.c will register name as a.b.c return __mpkg_ret # pylint: disable=undefined-variable  # noqa else : return importlib . import_module ( name ) except ImportError as e : if USE_MINIMAL : # e.g., tesorflow.compat.v1 should report tensorflow if "." in name : name = name . split ( "." ) [ 0 ] # trim the local version started by '+', if there's any pos = __version__ . rfind ( "+" ) if pos != - 1 : version = __version__ [ : pos ] else : version = __version__ # append more information from Import error emsg = str ( e ) emsg = ( "{}.\nThis is a minimal package for SFrame only, without {} pinned" " as a dependency. You can try install all required packages by installing" " the full package. For example:\n" "pip install --force-reinstall turicreate=={}\n" ) . format ( emsg , name , version ) if six . PY2 : # __str__ and __repr__ uses `args`. # only change the first element of args tuple args = list ( e . args ) if args : args [ 0 ] = emsg else : args = ( emsg , ) e . args = tuple ( args ) e . message = emsg else : e . msg = emsg raise e