Module paths

ooodev.utils.paths.find_program_directory(start_path)[source]

Finds the program directory in the path.

Parameters:

start_path (str) – Path to start search from.

Returns:

Path to program directory or None if not found.

Return type:

Path | None

ooodev.utils.paths.get_lo_path()[source]

Searches known paths for path that contains LibreOffice soffice.

This path is different for windows and linux. Typically for Windows C:\Program Files\LibreOffice\program Typically for Linux /usr/bin/soffice

Raises:
  • FileNotFoundError – if path is not found

  • NotADirectoryError – if path is not a directory

Returns:

First found path.

Return type:

Path

ooodev.utils.paths.get_lo_python_ex()[source]

Gets the python executable for different environments.

In Linux this is the current python executable. If a virtual environment is activated then that will be the python executable that is returned.

In Windows this is the python.exe file in LibreOffice. Typically for Windows C:\Program Files\LibreOffice\program\python.exe

Raises:
  • FileNotFoundError – In Windows if python.exe is not found.

  • NotADirectoryError – In Windows if python.exe is not a file.

Returns:

file location of python executable.

Return type:

str

ooodev.utils.paths.get_soffice_install_path()[source]

Gets the Soffice install path.

For windows this will be something like: C:\Program Files\LibreOffice. For Linux this will be something like: /usr/lib/libreoffice

Returns:

install as Path.

Return type:

Path

ooodev.utils.paths.get_soffice_path(check_env=True)[source]

Gets path to soffice

Parameters:

check_env (bool, optional) – If True then check environment variable ODEV_CONN_SOFFICE for path. Defaults to True.

Returns:

path to soffice

Return type:

Path

Changed in version 0.11.6: Added check_env parameter.

ooodev.utils.paths.get_uno_path()[source]

Searches known paths for path that contains uno.py

This path is different for windows and linux. Typically for Windows C:\Program Files\LibreOffice\program Typically for Linux /usr/lib/python3/dist-packages

Raises:
  • FileNotFoundError – if path is not found

  • NotADirectoryError – if path is not a directory

Returns:

First found path.

Return type:

Path

ooodev.utils.paths.get_virtual_env_path()[source]

Gets the Virtual Environment Path

Returns:

Virtual Environment Path

Return type:

str

Note

If unable to get virtual path from Environment then sys.base_exec_prefix is returned.

ooodev.utils.paths.get_virtual_env_site_packages_path()[source]

Gets the Virtual Environment site_packages Path

Returns:

Virtual Environment Path

Return type:

str

Note

If unable to get virtual path from Environment then sys.base_exec_prefix is returned.

New in version 0.11.7.

ooodev.utils.paths.mkdirp(dest_dir: str)[source]
ooodev.utils.paths.mkdirp(dest_dir: pathlib.Path)
ooodev.utils.paths.mkdirp(dest_dir)

Creates path and sub paths not existing.

Parameters:

dest_dir (str | PathLike]) – PathLike object

Return type:

None