def to_trait(self, notification_body):
        values = [match for match in self.fields.find(notification_body)
                  if match.value is not None]

        if self.plugin is not None:
            value_map = [('.'.join(self._get_path(match)), match.value) for
                         match in values]
            value = self.plugin.trait_value(value_map)
        else:
            value = values[0].value if values else None

        if value is None:
            return None

        # NOTE(mdragon): some openstack projects (mostly Nova) emit ''
        # for null fields for things like dates.
        if self.trait_type != Datatype.text and value == '':
            return None

        value = self.trait_type.convert(value)
        return Trait(self.name, self.trait_type, value)
dataset/ETHPy150Open openstack/stacktach-stackdistiller/stackdistiller/distiller.py/TraitDefinition.to_trait/original