From 29079f22c7b0b25fac56f45bc05d726598c2b6eb Mon Sep 17 00:00:00 2001 From: Alina Lenk Date: Sun, 15 May 2022 00:32:56 +0200 Subject: [PATCH 15/18] generate_packets.py: replace custom formatting code in Variant.get_send() See osdn#44603 Signed-off-by: Alina Lenk --- common/generate_packets.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/common/generate_packets.py b/common/generate_packets.py index a95bb12061..3449c06d9d 100755 --- a/common/generate_packets.py +++ b/common/generate_packets.py @@ -1208,13 +1208,6 @@ static char *stats_{self.name}_names[] = {{{names}}}; # function. This is one of the two real functions. So it is rather # complex to create. def get_send(self): - temp='''%(send_prototype)s -{ - SEND_PACKET_START(%(type)s); - SEND_PACKET_END(%(type)s); -} - -''' if self.gen_stats: report=''' stats_total_sent++; @@ -1308,13 +1301,30 @@ static char *stats_{self.name}_names[] = {{{names}}}; ''' + delta_header2 else: delta_header = delta_header + delta_header2 - for i in range(2): - for k,v in vars().items(): - if type(v)==type(""): - temp=temp.replace("<%s>"%k,v) - return temp%self.get_dict(vars()) - # ''' + return "".join(( + """\ +%(send_prototype)s +{ +""", + real_packet1, + delta_header, + """\ + SEND_PACKET_START(%(type)s); +""", + faddr, + log, + report, + pre1, + body, + pre2, + post, + """\ + SEND_PACKET_END(%(type)s); +} + +""", + )) % self.get_dict(vars()) # Helper for get_send() def get_delta_send_body(self, before_return=""): -- 2.17.1