+ def get_property(self, prop):
+ """ Retrieve the value for a single property key
+
+ :param prop: The name of the property to get.
+ :returns: String with the property value or None if there is no such
+ key. In the case of multiple values for the given key, the
+ first one is retrieved.
+ :raises: :exc:`NotInitializedError` if message has not been
+ initialized
+ """
+ if not self._msg:
+ raise NotInitializedError()
+
+ value = c_char_p()
+ status = Message._get_property(self._msg, _str(prop), byref(value))
+ if status != 0:
+ raise NotmuchError(status)
+
+ return value.value.decode('utf-8') if value is not None else None
+
+ def get_properties(self, prop="", exact=False):
+ """ Get the properties of the message, returning a generator of
+ name, value pairs.
+
+ The generator will yield once per value. There might be more than one
+ value on each name, so the generator might yield the same name several
+ times.
+
+ :param prop: The name of the property to get. Otherwise it will return
+ the full list of properties of the message.
+ :param exact: if True, require exact match with key. Otherwise
+ treat as prefix.
+ :yields: Each property values as a pair of `name, value`
+ :ytype: pairs of str
+ :raises: :exc:`NotInitializedError` if message has not been
+ initialized
+ """
+ if not self._msg:
+ raise NotInitializedError()
+
+ properties = Message._get_properties(self._msg, _str(prop), exact)
+ while Message._properties_valid(properties):
+ key = Message._properties_key(properties)
+ value = Message._properties_value(properties)
+ yield key.decode("utf-8"), value.decode("utf-8")
+ Message._properties_move_to_next(properties)
+