na.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. from __future__ import annotations
  2. from contextlib import contextmanager
  3. from .base import AppData, ContentStore
  4. class AppDataDisabled(AppData):
  5. """No application cache available (most likely as we don't have write permissions)."""
  6. transient = True
  7. can_update = False
  8. def __init__(self) -> None:
  9. pass
  10. error = RuntimeError("no app data folder available, probably no write access to the folder")
  11. def close(self):
  12. """Do nothing."""
  13. def reset(self):
  14. """Do nothing."""
  15. def py_info(self, path): # noqa: ARG002
  16. return ContentStoreNA()
  17. def embed_update_log(self, distribution, for_py_version): # noqa: ARG002
  18. return ContentStoreNA()
  19. def extract(self, path, to_folder): # noqa: ARG002
  20. raise self.error
  21. @contextmanager
  22. def locked(self, path): # noqa: ARG002
  23. """Do nothing."""
  24. yield
  25. @property
  26. def house(self):
  27. raise self.error
  28. def wheel_image(self, for_py_version, name): # noqa: ARG002
  29. raise self.error
  30. def py_info_clear(self):
  31. """Nothing to clear."""
  32. class ContentStoreNA(ContentStore):
  33. def exists(self):
  34. return False
  35. def read(self):
  36. """Nothing to read."""
  37. return
  38. def write(self, content):
  39. """Nothing to write."""
  40. def remove(self):
  41. """Nothing to remove."""
  42. @contextmanager
  43. def locked(self):
  44. yield
  45. __all__ = [
  46. "AppDataDisabled",
  47. "ContentStoreNA",
  48. ]