labtools/_src/util.py
def require(*names: str):
  """Create a decorator to check if a package is installed.

  Args:
    *names: name of the package(s).

  """
  msg = '%s requires %s, but %s not installed.'

  def wrapped_with_params(fn):
    @wraps(fn)
    def _require(*args, **kwargs):
      missing_pkgs = list(T.filter(T.complement(is_installed), names))
      if missing_pkgs == []:
        # if is_installed(name):
        return fn(*args, **kwargs)
      elif len(missing_pkgs) == 1:
        raise ImportError(msg % (fn.__name__, missing_pkgs[0], 'it is'))
      else:
        nice_names = ', '.join(missing_pkgs)
        raise ImportError(msg % (fn.__name__, nice_names, 'they are'))

    return _require

  return wrapped_with_params
Create a decorator to check if a package is installed.

  Args:
    *names: name of the package(s).

  
Create a decorator to check if a package is installed.
Create a decorator to check if a package is installed .
def require(*names: str):
  msg = '%s requires %s, but %s not installed.'
  def wrapped_with_params(fn):
    @wraps(fn)
    def _require(*args, **kwargs):
      missing_pkgs = list(T.filter(T.complement(is_installed), names))
      if missing_pkgs == []:
        return fn(*args, **kwargs)
      elif len(missing_pkgs) == 1:
        raise ImportError(msg % (fn.__name__, missing_pkgs[0], 'it is'))
      else:
        nice_names = ', '.join(missing_pkgs)
        raise ImportError(msg % (fn.__name__, nice_names, 'they are'))
    return _require
  return wrapped_with_params
def require ( * names : str ) : msg = '%s requires %s, but %s not installed.' def wrapped_with_params ( fn ) : @ wraps ( fn ) def _require ( * args , ** kwargs ) : missing_pkgs = list ( T . filter ( T . complement ( is_installed ) , names ) ) if missing_pkgs == [ ] : return fn ( * args , ** kwargs ) elif len ( missing_pkgs ) == 1 : raise ImportError ( msg % ( fn . __name__ , missing_pkgs [ 0 ] , 'it is' ) ) else : nice_names = ', ' . join ( missing_pkgs ) raise ImportError ( msg % ( fn . __name__ , nice_names , 'they are' ) ) return _require return wrapped_with_params
Create a decorator to check if a package is installed.
Create a decorator to check if a package is installed .
"""Create a decorator to check if a package is installed.

  Args:
    *names: name of the package(s).

  """ # if is_installed(name):
names
str
*names
name of the package(s).
name of the package ( s ) .