ogs5py.tools.script

Script generator for ogs5py.

Generator

gen_script(ogs_class[, script_dir, …]) Generate a python script for the given model.

Helpers

formater(val) Format values as string.
get_line(cont_line) Create content line for the script.
tab(num) Get tab indentation.
add_block_file(block_file, script[, …]) Add block-file creation to script.
add_load_file(load_file, script[, ogs_cls_name]) Add a file to be loaded from a script.
add_list_file(list_file, script, typ[, …]) Add a listed file to be loaded from a script.

add_block_file(block_file, script, ogs_cls_name='model')[source]

Add block-file creation to script.

Parameters:
  • block_file (BlockFile) – BlockFile class to be added to the script
  • script (stream) – given opened file for the script
  • ogs_cls_name (str) – name of the model within the script
add_list_file(list_file, script, typ, ogs_cls_name='model')[source]

Add a listed file to be loaded from a script.

Parameters:
  • list_file (File) – listed file that should be saved and then loaded from the script
  • script (stream) – given opened file for the script
  • typ (str) – typ of the list file
  • ogs_cls_name (str) – name of the model within the script
add_load_file(load_file, script, ogs_cls_name='model')[source]

Add a file to be loaded from a script.

Parameters:
  • load_file (OGSFile) – file that should be saved and then loaded from the script
  • script (stream) – given opened file for the script
  • ogs_cls_name (str) – name of the model within the script
formater(val)[source]

Format values as string.

Parameters:val (value) – input value to be formatted
gen_script(ogs_class, script_dir='/home/docs/checkouts/readthedocs.org/user_builds/ogs5py/checkouts/stable/docs/source/ogs_script', script_name='model.py', ogs_cls_name='model', task_root=None, task_id=None, output_dir=None, separate_files=None)[source]

Generate a python script for the given model.

Parameters:
  • ogs_class (OGS) – model class to be converted to a script
  • script_dir (str) – target directory for the script
  • script_name (str) – name for the script file (including .py ending)
  • ogs_cls_name (str) – name of the model in the script
  • task_root (str) – used task_root in the script
  • task_id (str) – used task_id in the script
  • output_dir (str) – used output_dir in the script
  • separate_files (list of str or None) – list of files, that should be written to separate files and then loaded from the script

Notes

This will only create BlockFiles from the script. GLI and MSH files as well as every listed or line-wise file will be stored separately.

get_line(cont_line)[source]

Create content line for the script.

Parameters:cont_line (list of values) – content line from a BlockFile
tab(num)[source]

Get tab indentation.

Parameters:num (int) – indentation depth