def loggroups_to_flattern_list()

in aliyun/log/pulllog_response.py [0:0]


    def loggroups_to_flattern_list(loggroup_list, time_as_str=None, decode_bytes=None):
        flatten_logs_json = []
        for logGroup in loggroup_list.LogGroups:
            tags = {}
            for tag in logGroup.LogTags:
                tags[u"__tag__:{0}".format(tag.Key)] = tag.Value

            for log in logGroup.Logs:
                item = {u'__time__': six.text_type(log.Time) if time_as_str else log.Time,
                        u'__topic__': logGroup.Topic,
                        u'__source__': logGroup.Source}
                if log.Time_ns:
                    item[u'__time_ns_part__'] = six.text_type(log.Time_ns) if time_as_str else log.Time_ns,
                item.update(tags)
                for content in log.Contents:
                    item[PullLogResponse._b2u(content.Key) if decode_bytes else content.Key] = PullLogResponse._b2u(content.Value) if decode_bytes else content.Value
                flatten_logs_json.append(item)
        return flatten_logs_json