Skip to content

Commit

Permalink
Update stopevents_gen.py
Browse files Browse the repository at this point in the history
Updated the python code using the enumerate function, which will eliminate
the need for an explicit index variable "i". It also uses f-strings for
cleaner string formatting.
  • Loading branch information
MatheusFarias03 authored and akorotkov committed Nov 9, 2023
1 parent e6e4ac8 commit a6cb5cd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions stopevents_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@

f = open('include/utils/stopevents_defs.h', 'w')
f.write('/* Generated file, see stopevents_gen.py */\n\n')
i = 0
for e in event_names:
f.write('#define STOPEVENT_' + e.upper() + ' (' + str(i) + ')\n')
i = i + 1
f.write('#define STOPEVENTS_COUNT (' + str(i) + ')\n')

for i, e in enumerate(event_names):
f.write(f'#define STOPEVENT_{e.upper()} ({str(i)})\n')

f.write('#define STOPEVENTS_COUNT (' + str(len(event_names)) + ')\n')
f.close()

f = open('include/utils/stopevents_data.h', 'w')
f.write('/* Generated file, see stopevents_gen.py */\n\n')
i = 0

for e in event_names:
f.write('"' + e + '",\n')
i = i + 1
f.write(f'"{e}",\n')

f.close()

0 comments on commit a6cb5cd

Please sign in to comment.