geosoft.gxpy.metadata submodule¶
Geosoft metadata.
Classes: |
|
---|
See also
Note
Regression tests provide usage examples: metadata tests
-
META_INVALID
= -1¶
-
META_ROOT_NODE
= -100¶
-
META_TYPE_ATTRIBUTE
= 1¶
-
META_TYPE_NODE
= 0¶
-
class
Metadata
(metadata=None)¶ Bases:
object
Simple interface to work with Geosoft metadata objects :class::
geosoft.gxapi.GXMETA
.Parameters: gxmeta – Geosoft geosoft.gxapi.GXMETA
instance, or None (default) in which case an empty metadata instance is created.Geosoft metadata objects contain metadata organized as a tree of information, with each node of the tree containing 0 or more attributes and 0 or more nested nodes.
While geosoft metadata can contain custom typed attributes and indeed any Geosoft object, this simple interface currently supports only Python types int, float, string and Python structures like tuple, arrays and dictionaries.
Nodes are identified by a string in the form:
/node/[...]/
(eg.'/geosoft/data/'
).Attributes are identified by a string in the form
/node/[...]/attribute
(eg.'geosoft/data/keywords'
).New in version 9.3.
-
attribute_token
(attr_name)¶ Returns the metadata token (integer) of an attribute.
Parameters: attribute_name – name of the attribute (eg. 'my_metadata/parameters/frequency'
)Returns: metadata token number or META_INVALID
if the attribute does not exist...versionadded::9.3
-
get_attribute
(attr_name)¶ Retrieve an attribute setting.
Parameters: attr_name – attribute name (eg. ‘/my_metadata/parameters/frequency’) Returns: attribute setting
-
gxmeta
¶ The
geosoft.gxapi.GXMETA
instance handle...versionadded:: 9.3
-
has_attribute
(attribute_name)¶ Returns
True
if this attribute exists in the metadata.Parameters: attribute_name – name of a attribute (eg. 'geosoft/data/keywords'
)New in version 9.3.
-
has_node
(node_name)¶ Returns
True
if this node exists in the metadata.Parameters: node_name – name of a node (eg. 'geosoft/data/'
)New in version 9.3.
-
meta_dict
()¶ Metadata content as a dictionary. Geosoft objects will appear as descriptive text strings.
Returns: dictionary of metadata New in version 9.3.
-
meta_type
(meta_name)¶ Return if this is a node (
META_TYPE_NODE
) or an attribute (META_TYPE_ATTRIBUTE
).Returns
META_INVALID
if neither.Parameters: meta_name – New in version 9.3.
-
node_attribute_token
(attr_name)¶ returns the node and attribute number of an attribute.
Parameters: attr_name – attribute name Returns: (node token, attribute token) ..versionadded:: 9.3
-
node_token
(node_name)¶ Returns the metadata token (integer) of a node. The node is created if it does not exist.
Parameters: node_name – name of the node (eg. 'my_metadata/parameters'
)Returns: metadata token number ..versionadded::9.3
-
set_attribute
(attr_name, value)¶ Set an attribute to a value. The attribute is created if it does not exist.
Parameters: - attr_name – attribute name (eg.
'/my_metadata/parameters/frequency'
) - value – int, float, string or a Python structure such as tuple, array or dict.
..versionadded:: 9.3
- attr_name – attribute name (eg.
-
-
exception
MetadataException
¶ Bases:
Exception
Exceptions from
geosoft.gxpy.metadata
.New in version 9.3.