pytuflow.TOC.append_input#
- TOC.append_input(input_text, gap=0)#
Appends a new input to the end of the control file.
- Parameters:
input_text (str | T_Input) –
The input text to add to the control file (i.e. the TUFLOW command). Leading whitespace will be respected. However, the input will be indented automatically depending on its scope and generally is not required to be considered by the user in the input text.
Alternatively, an existing input instance can be passed in. If the input does not already exist in the control file, the input instance will be added directly. If the input already exists within the control file, a copy of the input will be made and added.
gap (int, optional) – The number of blank lines to add before the new input. This has no impact on the TUFLOW model, but can be useful for readability of the control file when it is written to disk. Default is 0.
- Returns:
The input that was added. The input type will be determined by the
input_text
string e.g. if the text isRead GIS Z Shape == ...
, then the return input will be of typeGisInput
.- Return type:
T_Input
Examples
1! Control File 2Solution Sceme == HPC 3Hardware == GPU
The following code appends a new input to the end of the control file:
>>> cf = ... # assume this is the loaded control file object >>> inp = cf.append_input('SGS == On') >>> inp <SettingInput> SGS == On
The content of the control file can be previewed using
preview()
:>>> cf.preview() Solution Scheme == HPC Hardware == GPU SGS == On
The new input is not written to disk until
write()
is called.undo()
can be used to revert the last change made to the control file, which in this case would remove the new command.