resqpy.olio.base.BaseResqpy

class resqpy.olio.base.BaseResqpy(model, uuid=None, title=None, originator=None, extra_metadata=None)[source]

Bases: object

Base class for generic resqpy classes.

Implements generic attributes such as uuid, root, part, title, originator.

Implements generic magic methods, such as pretty printing and testing for equality.

Example use:

class AnotherResqpyObject(BaseResqpy):

    resqml_type = 'obj_anotherresqmlobjectrepresentation'

Public Data Attributes:

resqml_type

Definition of which RESQML object the class represents.

part

Standard part name corresponding to self.uuid.

root

XML node corresponding to self.uuid.

citation_title

Citation block title equivalent to self.title.

Methods:

__init__(model[, uuid, title, originator, ...])

Load an existing resqml object, or create new.

try_reuse()

Look for an equivalent existing RESQML object and modify the uuid of this object if found.

create_xml([title, originator, ...])

Write citation block to XML.

append_extra_metadata(meta_dict)

Append a given dictionary of metadata to the existing metadata.

__eq__(other)

Implements equals operator; uses is_equivalent() otherwise compares class type and uuid.

__ne__(other)

Implements not equal operator.

__repr__()

String representation.


abstract property resqml_type

Definition of which RESQML object the class represents.

Subclasses must overwrite this abstract attribute.

__init__(model, uuid=None, title=None, originator=None, extra_metadata=None)[source]

Load an existing resqml object, or create new.

Parameters
  • model (resqpy.model.Model) – Parent model

  • uuid (str, optional) – Load from existing uuid (if given), else create new.

  • title (str, optional) – Citation title

  • originator (str, optional) – Creator of object. By default, uses user id.

uuid

Unique identifier

title

Citation title

originator

Creator of object. By default, user id.

property part

Standard part name corresponding to self.uuid.

property root

XML node corresponding to self.uuid.

property citation_title

Citation block title equivalent to self.title.

try_reuse()[source]

Look for an equivalent existing RESQML object and modify the uuid of this object if found.

Returns

boolean – True if an equivalent object was found, False if not

Note

by design this method may change this object’s uuid as a side effect

create_xml(title=None, originator=None, extra_metadata=None, add_as_part=False)[source]

Write citation block to XML.

Note

add_as_part is False by default in this base method. Derived classes should typically extend this method to complete the XML representation, and then finally ensure the node is added as a part to the model.

Parameters
  • title (string) – used as the citation Title text

  • originator (string, optional) – the name of the human being who created the deviation survey part; default is to use the login name

  • extra_metadata (dict, optional) – extra metadata items to be added

  • add_as_part (boolean) – if True, the newly created xml node is added as a part in the model

Returns

node – the newly created root node

append_extra_metadata(meta_dict)[source]

Append a given dictionary of metadata to the existing metadata.