check_path.org 1.2 KB


  # Default value
  if fname_type is None:
      fname_type = " "
  # Make sure that fname_type is a string
  if isinstance(fname_type, str):
      # set blank space before and after
      fname_type = " " + fname_type.strip() + " "
  else:
      raise ValueError("fname_type must be a character string")

  if not path.exists(path.expandvars(fname)):
      raise ValueError("The" + fname_type + "file does not exist:  " + fname)

  def check_path(fname, fname_type=None):
      """
      Requires
      --------
      from os import path
      """
      # Default value
      if fname_type is None:
          fname_type = " "
      # Make sure that fname_type is a string
      if isinstance(fname_type, str):
          # set blank space before and after
          fname_type = " " + fname_type.strip() + " "
      else:
          raise ValueError("fname_type must be a character string")

      if not path.exists(path.expandvars(fname)):
          raise ValueError("The" + fname_type + "file does not exist:  " + fname)