__main__.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from __future__ import annotations
  2. from platformdirs import PlatformDirs, __version__
  3. PROPS = (
  4. "user_data_dir",
  5. "user_config_dir",
  6. "user_cache_dir",
  7. "user_state_dir",
  8. "user_log_dir",
  9. "user_documents_dir",
  10. "user_runtime_dir",
  11. "site_data_dir",
  12. "site_config_dir",
  13. )
  14. def main() -> None:
  15. app_name = "MyApp"
  16. app_author = "MyCompany"
  17. print(f"-- platformdirs {__version__} --")
  18. print("-- app dirs (with optional 'version')")
  19. dirs = PlatformDirs(app_name, app_author, version="1.0")
  20. for prop in PROPS:
  21. print(f"{prop}: {getattr(dirs, prop)}")
  22. print("\n-- app dirs (without optional 'version')")
  23. dirs = PlatformDirs(app_name, app_author)
  24. for prop in PROPS:
  25. print(f"{prop}: {getattr(dirs, prop)}")
  26. print("\n-- app dirs (without optional 'appauthor')")
  27. dirs = PlatformDirs(app_name)
  28. for prop in PROPS:
  29. print(f"{prop}: {getattr(dirs, prop)}")
  30. print("\n-- app dirs (with disabled 'appauthor')")
  31. dirs = PlatformDirs(app_name, appauthor=False)
  32. for prop in PROPS:
  33. print(f"{prop}: {getattr(dirs, prop)}")
  34. if __name__ == "__main__":
  35. main()