def write_single(self, sheet, data):
        """

        :param sheet:
        :param data: 报文对象， dict
        :param template:
        :return:
        """
        # if not get_data:
        #     def get_data(x):
        #         # print '=====', x
        #         for i in x:
        #             yield i
        #             if 'children' in i and i['children']:
        #                 for j in get_data(i['children']):
        #                     yield j
        #
        def _subs(sheet, subs, data):
            for d in data:
                if d:
                    for line in subs:
                        self.write_line(sheet, line, d)

        for line in self.template:
            if line['subs']:
                loop_name = line['field']
                d = data.get(loop_name, [{}])
                _subs(sheet, line['subs'], d)
            else:
                self.write_line(sheet, line, data)
def write_single ( self , sheet , data ) : def _subs ( sheet , subs , data ) : for d in data : if d : for line in subs : self . write_line ( sheet , line , d ) for line in self . template : if line [ 'subs' ] : loop_name = line [ 'field' ] d = data . get ( loop_name , [ { } ] ) _subs ( sheet , line [ 'subs' ] , d ) else : self . write_line ( sheet , line , data )
:param sheet:
        :param data: 报文对象， dict
        :param template:
        :return: