def get_tag(el): """ :returns: `geographic_msgs/KeyValue`_ message for `<tag>` *el* if any, None otherwise. """ pair = None key = el.get('k') if key != None: pair = KeyValue() pair.key = key pair.value = get_required_attribute(el, 'v') return pair
def get_tag(el): """ Get a KeyValue pair from a <tag> element. :returns: KeyValue pair if any, None otherwise. """ pair = None key = el.get('k') if key != None: pair = KeyValue() pair.key = key pair.value = get_required_attribute(el, 'v') return pair
def put(msg, key, val=''): """ Add KeyValue to message properties. :param msg: Message to update. :param key: Property key name. :param value: Corresponding value string (default ''). """ for prop in msg.props: if prop.key == key: # key already present, update value prop.value = str(val) return # key missing, append a new KeyValue pair msg.props.append(KeyValue(key=key, value=str(val)))