ResSimpy.Nexus.nexus_remove_object_from_file.RemoveObjectOperations
- class ResSimpy.Nexus.nexus_remove_object_from_file.RemoveObjectOperations(network: NexusNetwork | None, table_header: str, table_footer: str)[source]
Bases:
objectMethods:
__init__(network, table_header, table_footer)remove_object_from_memory_by_id(list_obj, ...)Directly removes an object from a list of objects based on the id attribute of that object.
check_for_empty_table(file, ...)Identifies the lines needed to be removed if the table is empty.
Removes lines from the file content and removes any references to the object in the line locations in the file.
remove_object_by_id(file, obj_id, obj_list)Remove an object from a file and from the list of stored objects.
Removes object from file and from the list of objects based on matching a set of attributes provided in a dictionary or a unique id.
- __init__(network: NexusNetwork | None, table_header: str, table_footer: str) None[source]
- static remove_object_from_memory_by_id(list_obj: list[T], id_to_remove: UUID) tuple[Any, list[Any]][source]
Directly removes an object from a list of objects based on the id attribute of that object.
- check_for_empty_table(file: NexusFile, line_numbers_in_file_to_remove: list[int], obj_id: UUID) list[int][source]
Identifies the lines needed to be removed if the table is empty.
- Parameters:
file (NexusFile) – file to check
line_numbers_in_file_to_remove (list[int]) – list of line indices for the object being removed
obj_id (UUID) – id of the object being removed
- Returns:
A list of integers with the lines to remove from the file if the resulting table is empty after the lines associated with the removed object is removed
- remove_lines_from_file(line_numbers_in_file_to_remove: list[int], file: NexusFile, obj_id: UUID) None[source]
Removes lines from the file content and removes any references to the object in the line locations in the file.
- Parameters:
line_numbers_in_file_to_remove (list[int]) – line indices to be removed. Relative to the flattened file.
file (NexusFile) – NexusFile to remove the lines from. Lines nested in files will be resolved correctly.
obj_id (UUID) – id of the object being removed
- remove_object_by_id(file: NexusFile, obj_id: UUID, obj_list: list[T]) None[source]
Remove an object from a file and from the list of stored objects.
- Parameters:
file (NexusFile) – file to remove the lines associated with the obj from.
obj_id (UUID) – id of the object being removed.
obj_list (list[Any]) – list of corresponding objects.
- remove_object_from_network_main(obj_to_remove: dict[str, None | str | float | int] | UUID, network_element_name: Literal['nodes', 'connections', 'well_connections', 'wellheads', 'wellbores', 'constraints', 'targets'], existing_objects: list[T]) None[source]
Removes object from file and from the list of objects based on matching a set of attributes provided in a dictionary or a unique id.
- Parameters:
obj_to_remove (dict[str, None | str | float | int] | UUID) – dictionary of properties for identifying which
id. (object to remove. Can also take an object) –
network_element_name (str) – One of: ‘nodes’, ‘connections’, ‘well_connections’, ‘wellheads’, ‘wellbores’,
network ('constraints'. Identifies the attribute name of the element inside the) –
existing_objects (list[T]) – list of all existing network objects for the network element. e.g. self.__nodes