Skip to content

Io

Implements methods for reading and writing files.

decompress(input_file)

Decompress a gzipped file to a temporary file.

Yields the path to the decompressed temporary file and cleans it up on exit. If the input file is not gzipped, yields the original file path

PARAMETER DESCRIPTION
input_file

Path to any file, possibly gzip-compressed.

TYPE: str

YIELDS DESCRIPTION

Path to the decompressed file.

get_file_ext(file_path)

Get the file extension from a file path.

PARAMETER DESCRIPTION
file_path

Path to file.

RETURNS DESCRIPTION
str

File extension.

mgltools_env_exists()

Whether the mgltools pixi environment is installed. Never installs.

run_mgltools_command(cmd, auto_install=False, **subprocess_kwargs)

Run a command inside the isolated mgltools pixi environment.

PARAMETER DESCRIPTION
cmd

Command and arguments to run

TYPE: list[str]

auto_install

Install the environment if missing. Defaults is False

TYPE: bool DEFAULT: False

**subprocess_kwargs

Additional kwargs passed to subprocess.run

DEFAULT: {}

RETURNS DESCRIPTION
CompletedProcess

The CompletedProcess result.

write_text(text, write_path=None, file_ext=None)

General method to write text files.

PARAMETER DESCRIPTION
text

Text to write to file.

write_path

Path to write to file. If None, then a NamedTemporaryFile will be created instead.

file_ext

Specify the file extension if write_path is None.

RETURNS DESCRIPTION
str

Path to file that was just written.