ogs5py.fileclasses.asc

Class for the ogs ASC file.

File Class

ASC(**OGS_Config) Class for the ogs ASC file.

class ASC(**OGS_Config)[source]

Bases: ogs5py.fileclasses.base.LineFile

Class for the ogs ASC file.

Parameters:
  • lines (list of str, optional) – content of the file as a list of lines Default: None
  • name (str, optional) – name of the file without extension Default: “textfile”
  • task_root (str, optional) – Path to the destiny folder. Default: cwd+”ogs5model”
  • task_id (str, optional) – Name for the ogs task. (a place holder) Default: “model”

Notes

This is just handled as a line-wise file. You can access the data by line with:

ASC.lines

This file type comes either from .tim .pcs or .gem

Attributes:
file_name

str: base name of the file with extension.

file_path

str: save path of the file.

force_writing

bool: state if the file is written even if empty.

is_empty

bool: state if the file is empty.

name

str: name of the file without extension.

Methods

add_copy_link(self, path[, symlink]) Add a link to copy a file instead of writing.
check(self[, verbose]) Check if the given text-file is valid.
del_copy_link(self) Remove a former given link to an external file.
get_file_type(self) Get the OGS file class name.
read_file(self, path[, encoding, verbose]) Read an existing OGS input file.
reset(self) Delete every content.
save(self, path) Save the actual line-wise file in the given path.
write_file(self) Write the actual OGS input file to the given folder.

Add a link to copy a file instead of writing.

Instead of writing a file, you can give a path to an existing file, that will be copied/linked to the target folder.

Parameters:
  • path (str) – path to the existing file that should be copied
  • symlink (bool, optional) – on UNIX systems it is possible to use a symbolic link to save time if the file is big. Default: False
check(self, verbose=True)

Check if the given text-file is valid.

Parameters:verbose (bool, optional) – Print information for the executed checks. Default: True
Returns:result – Validity of the given file.
Return type:bool

Remove a former given link to an external file.

get_file_type(self)

Get the OGS file class name.

read_file(self, path, encoding=None, verbose=False)

Read an existing OGS input file.

Parameters:
  • path (str) – path to the existing file that should be read
  • encoding (str or None, optional) – encoding of the given file. If None is given, the system standard is used. Default: None
  • verbose (bool, optional) – Print information of the reading process. Default: False
reset(self)

Delete every content.

save(self, path)

Save the actual line-wise file in the given path.

Parameters:path (str) – path to where to file should be saved
write_file(self)

Write the actual OGS input file to the given folder.

Its path is given by “task_root+task_id+file_ext”.

file_name

base name of the file with extension.

Type:str
file_path

save path of the file.

Type:str
force_writing

state if the file is written even if empty.

Type:bool
is_empty

state if the file is empty.

Type:bool
name

name of the file without extension.

Type:str