ogstools.ogs6py.python_script module#

class ogstools.ogs6py.python_script.PythonScript[source]#

Bases: BuildTree, StorageBase

Class managing the python script file (.py) for an OGS project.

Tracks both the XML reference to the script and the actual file, enabling proper save/copy operations.

Initialize a PythonScript object.

Parameters:

tree (ElementTree) – The Project’s XML ElementTree (shared reference)

__init__(tree)[source]#

Initialize a PythonScript object.

Parameters:

tree (ElementTree) – The Project’s XML ElementTree (shared reference)

property filename: str | None#

Get the python script filename from the XML tree.

add_python_script(file_pathname)[source]#

Add/set a python script file.

Parameters:

file_pathname (str | Path) – The file path and name of the python script

Return type:

None

set_pyscript(filename)[source]#

Set a filename for a python script.

Parameters:

filename (str)

Return type:

None

save(target=None, overwrite=None, dry_run=False, archive=False, id=None)[source]#

Save the python script file.

Parameters:
  • target (Path | str | None) – Optional target path

  • overwrite (bool | None) – If True, overwrite existing files

  • dry_run (bool) – If True, simulate without writing

  • archive (bool) – If True, materialize symlinks

  • id (str | None) – Optional identifier. Mutually exclusive with target.

Return type:

list[Path]

Returns:

List of saved file paths