Skip to content

GreenGraph

greengraph

cache_dir_path

cache_dir_path()

Returns the path to the application cache directory.

Source code in greengraph/__init__.py
def cache_dir_path():
    """Returns the path to the application cache directory."""
    if not APP_CACHE_BASE_DIR.exists():
        logging.info(f"No cache directory exists. This directory is created only by some download functions.")
        return None
    else:
        logging.info(f"Cache directory located at: {APP_CACHE_BASE_DIR}.")
        return APP_CACHE_BASE_DIR

remove_cache_dir

remove_cache_dir()

Removes the application cache directory.

Source code in greengraph/__init__.py
def remove_cache_dir():
    """Removes the application cache directory."""
    if APP_CACHE_BASE_DIR.exists():
        try:
            shutil.rmtree(APP_CACHE_BASE_DIR)
            logging.info(f"Cache directory {APP_CACHE_BASE_DIR} removed successfully.")
        except OSError as e:
            logging.error(f"Error removing cache directory {APP_CACHE_BASE_DIR}: {e}")
    else:
        logging.info(f"Cache directory {APP_CACHE_BASE_DIR} does not exist. Nothing to remove.")