__init__.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from typing import Any, Optional
  2. from .main import (dotenv_values, find_dotenv, get_key, load_dotenv, set_key,
  3. unset_key)
  4. def load_ipython_extension(ipython: Any) -> None:
  5. from .ipython import load_ipython_extension
  6. load_ipython_extension(ipython)
  7. def get_cli_string(
  8. path: Optional[str] = None,
  9. action: Optional[str] = None,
  10. key: Optional[str] = None,
  11. value: Optional[str] = None,
  12. quote: Optional[str] = None,
  13. ):
  14. """Returns a string suitable for running as a shell script.
  15. Useful for converting a arguments passed to a fabric task
  16. to be passed to a `local` or `run` command.
  17. """
  18. command = ['dotenv']
  19. if quote:
  20. command.append('-q %s' % quote)
  21. if path:
  22. command.append('-f %s' % path)
  23. if action:
  24. command.append(action)
  25. if key:
  26. command.append(key)
  27. if value:
  28. if ' ' in value:
  29. command.append('"%s"' % value)
  30. else:
  31. command.append(value)
  32. return ' '.join(command).strip()
  33. __all__ = ['get_cli_string',
  34. 'load_dotenv',
  35. 'dotenv_values',
  36. 'get_key',
  37. 'set_key',
  38. 'unset_key',
  39. 'find_dotenv',
  40. 'load_ipython_extension']