Utilities¶
Utilities package for guidata.
Miscellaneous utility functions¶
Running programs¶
- guidata.utils.misc.run_program(name, args: str = '', cwd: str = None, shell: bool = True, wait: bool = False) None¶
Run program in a separate process.
- Parameters:
- Raises:
RuntimeError – If program is not installed.
- guidata.utils.misc.is_program_installed(basename: str) str | None¶
Return program absolute path if installed in PATH, otherwise None.
- guidata.utils.misc.run_shell_command(cmdstr, **subprocess_kwargs)¶
Execute the given shell command.
Note that args and kwargs will be passed to the subprocess call.
If ‘shell’ is given in subprocess_kwargs it must be True, otherwise ProgramError will be raised.
If ‘executable’ is not given in subprocess_kwargs, it will be set to the value of the SHELL environment variable.
Note that stdin, stdout and stderr will be set by default to PIPE unless specified in subprocess_kwargs.
- Str cmdstr:
The string run as a shell command.
- Subprocess_kwargs:
These will be passed to subprocess.Popen.
Strings¶
Translations utilities¶
Description¶
This module provides utilities for managing translations in guidata. It is based on Babel.
Three functions are provided:
scan_translations(): Extracts translatable strings from Python files and generates translation files.compile_translations(): Compiles translation files into binary format.main(): Convenience function to callscan_translations()orcompile_translations()with command-line arguments.
Usage¶
To extract translatable strings and generate translation files, use:
$ # Scan translations
$ python -m guidata.utils.translations scan --name <name> --directory <directory>
$ # Alternatively, you can use the command-line tool:
$ guidata-translations scan --name <name> --directory <directory>
To compile translation files into binary format, use:
$ # Compile translations
$ python -m guidata.utils.translations compile --name <name> --directory <directory>
$ # Alternatively, you can use the command-line tool:
$ guidata-translations compile --name <name> --directory <directory>