path.py 834 B

123456789101112131415161718192021
  1. """Path utils"""
  2. from __future__ import annotations
  3. from pathlib import Path
  4. from typing import TYPE_CHECKING
  5. if TYPE_CHECKING:
  6. from ..base import HacsBase
  7. def is_safe(hacs: HacsBase, path: str | Path) -> bool:
  8. """Helper to check if path is safe to remove."""
  9. return Path(path).as_posix() not in (
  10. Path(f"{hacs.core.config_path}/{hacs.configuration.appdaemon_path}").as_posix(),
  11. Path(f"{hacs.core.config_path}/{hacs.configuration.netdaemon_path}").as_posix(),
  12. Path(f"{hacs.core.config_path}/{hacs.configuration.plugin_path}").as_posix(),
  13. Path(f"{hacs.core.config_path}/{hacs.configuration.python_script_path}").as_posix(),
  14. Path(f"{hacs.core.config_path}/{hacs.configuration.theme_path}").as_posix(),
  15. Path(f"{hacs.core.config_path}/custom_components/").as_posix(),
  16. )