labtools/_src/util.py
def is_installed(name: str) -> bool:
  """ Checks if a module is installed.
  Args:
    name: name of the module. If name is for a submodule (contains a dot) and
      the parent module is not installed, `importlib.util.find_spec` will raise
      a `ModuleNotFoundError`. We catch these errors and return False.
  """
  try:
    return find_spec(name) is not None
  except ModuleNotFoundError:
    return False
  except ValueError as inst:
    if str(inst).endswith('.__spec__ is None'):
      logging.info('Missing __spec__ for %s. Marking package as installed.',
                   str(inst).split('.', 1)[0])
      return True
    raise inst
  except:
    logging.exception('Unhandled exception for is_installed, returning False')
    return False
 Checks if a module is installed.
  Args:
    name: name of the module. If name is for a submodule (contains a dot) and
      the parent module is not installed, `importlib.util.find_spec` will raise
      a `ModuleNotFoundError`. We catch these errors and return False.
  
Checks if a module is installed.
Checks if a module is installed .
def is_installed(name: str) -> bool:
  try:
    return find_spec(name) is not None
  except ModuleNotFoundError:
    return False
  except ValueError as inst:
    if str(inst).endswith('.__spec__ is None'):
      logging.info('Missing __spec__ for %s. Marking package as installed.',
                   str(inst).split('.', 1)[0])
      return True
    raise inst
  except:
    logging.exception('Unhandled exception for is_installed, returning False')
    return False
def is_installed ( name : str ) -> bool : try : return find_spec ( name ) is not None except ModuleNotFoundError : return False except ValueError as inst : if str ( inst ) . endswith ( '.__spec__ is None' ) : logging . info ( 'Missing __spec__ for %s. Marking package as installed.' , str ( inst ) . split ( '.' , 1 ) [ 0 ] ) return True raise inst except : logging . exception ( 'Unhandled exception for is_installed, returning False' ) return False
Checks if a module is installed.
Checks if a module is installed .
""" Checks if a module is installed.
  Args:
    name: name of the module. If name is for a submodule (contains a dot) and
      the parent module is not installed, `importlib.util.find_spec` will raise
      a `ModuleNotFoundError`. We catch these errors and return False.
  """
name
str
name of the module. If name is for a submodule (contains a dot) and
the parent module is not installed, `importlib.util.find_spec` will raise
a `ModuleNotFoundError`. We catch these errors and return False.
name of the module . If name is for a submodule ( contains a dot ) and the parent module is not installed ` importlib . util . find_spec ` will raise a ` ModuleNotFoundError ` . We catch these errors and return False .