'Design a query based on the given WMIObject to extract a tag.
Returns: tag or TagQueryUniquenessFailure exception.'

def _get_tag_query_tag(self, sampler, wmi_obj, tag_query):

    self.log.debug(u'`tag_queries`    parameter    found.    wmi_object={wmi_obj}    -    query={tag_query}'.format(wmi_obj=wmi_obj, tag_query=tag_query))
    (target_class, target_property, filters) = self._format_tag_query(sampler, wmi_obj, tag_query)
    tag_query_sampler = WMISampler(self.log, target_class, [target_property], filters=filters, **sampler.connection)
    tag_query_sampler.sample()
    self._raise_on_invalid_tag_query_result(tag_query_sampler, wmi_obj, tag_query)
    link_value = str(tag_query_sampler[0][target_property]).lower()
    tag = '{tag_name}:{tag_value}'.format(tag_name=target_property.lower(), tag_value='_'.join(link_value.split()))
    self.log.debug(u"Extracted    `tag_queries`    tag:    '{tag}'".format(tag=tag))
    return tag
