resqpy.property.StringLookup¶
- class resqpy.property.StringLookup(parent_model, uuid=None, int_to_str_dict=None, title=None, extra_metadata=None, originator=None)¶
Bases:
BaseResqpy
Class catering for RESQML obj_StringLookupTable objects.
Public Data Attributes:
resqml_type
Inherited from
BaseResqpy
resqml_type
Standard part name corresponding to self.uuid.
XML node corresponding to self.uuid.
Citation block title equivalent to self.title.
Commonly Used Methods:
__init__
(parent_model[, uuid, ...])Creates a new string lookup (RESQML obj_StringTableLookup) object.
get_string
(key)Returns the string associated with the integer key, or None if not found.
get_list
()Returns a list of values, sorted by key.
length
()Returns the nominal length of the lookup table.
get_index_for_string
(string)Returns the integer key for the given string (exact match required), or None if not found.
create_xml
([title, originator, add_as_part, ...])Creates an xml node for the string table lookup.
Methods:
load_from_dict
(int_to_str_dict)Sets the contents of this string lookup based on a dict mapping int to str.
as_dict
()Returns the string lookup as a python dictionary.
is_equivalent
(other)Returns True if this lookup is the same as other (apart from uuid); False otherwise.
Sets a list copy of the lookup table, which can be indexed directly, if it makes sense to do so.
set_string
(key, value)Sets the string associated with a given integer key.
Inherited from
BaseResqpy
__init__
(parent_model[, uuid, ...])Creates a new string lookup (RESQML obj_StringTableLookup) object.
Look for an equivalent existing RESQML object and modify the uuid of this object if found.
create_xml
([title, originator, add_as_part, ...])Creates an xml node for the string table lookup.
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.
- __init__(parent_model, uuid=None, int_to_str_dict=None, title=None, extra_metadata=None, originator=None)[source]¶
Creates a new string lookup (RESQML obj_StringTableLookup) object.
- Parameters
parent_model – the model to which this string lookup belongs
uuid (optional) – if present, the uuid for an exising StringTableLookup from which this object is populated
int_to_str_dict (optional) – if present, a dictionary mapping from integers to strings, used to populate the lookup; ignored if uuid is present
title (string, optional) – if present, is used as the citation title for the object; ignored if uuid is not None
- Returns
the new StringLookup object
- append_extra_metadata(meta_dict)¶
Append a given dictionary of metadata to the existing metadata.
- property citation_title¶
Citation block title equivalent to self.title.
- create_xml(title=None, originator=None, add_as_part=True, reuse=True)[source]¶
Creates an xml node for the string table lookup.
- Parameters
title (string, optional) – if present, overrides the object’s title attribute to be used as citation title
originator (string, optional) – if present, used as the citation creator (otherwise login name is used)
add_as_part (boolean, default True) – if True, the property set is added to the model as a part
- get_index_for_string(string)[source]¶
Returns the integer key for the given string (exact match required), or None if not found.
- is_equivalent(other)[source]¶
Returns True if this lookup is the same as other (apart from uuid); False otherwise.
- load_from_dict(int_to_str_dict)[source]¶
Sets the contents of this string lookup based on a dict mapping int to str.
- property part¶
Standard part name corresponding to self.uuid.
- property root¶
XML node corresponding to self.uuid.
- set_list_from_dict_conditionally()[source]¶
Sets a list copy of the lookup table, which can be indexed directly, if it makes sense to do so.
- try_reuse()¶
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
- title¶
Citation title
- originator¶
Creator of object. By default, user id.
- uuid¶
Unique identifier