@@ -160,18 +160,34 @@ def make_events_data(data: dict) -> list[dict]:
160160 event ["expected_arguments" ] = signature (event_class ).parameters
161161
162162 if "func_evt" in event :
163- # replace the name of the function by something unique
164- func_evt = event ["func_evt" ]
165- func_evt = func_evt .replace ("def func_evt" , f"def { event ['name' ]} _func_evt" )
166- event ["func_evt" ] = f"{ event ['name' ]} _func_evt"
167- event ["func_evt_desc" ] = func_evt
168- if "func_act" in event :
169- # replace the name of the function by something unique
170- func_act = event ["func_act" ]
171- func_act = func_act .replace ("def func_act" , f"def { event ['name' ]} _func_act" )
172- event ["func_act" ] = f"{ event ['name' ]} _func_act"
173- event ["func_act_desc" ] = func_act
163+ # if the whole function in defined in the event, make sure it has a unique identifier
164+ if event ["func_evt" ].startswith ("def" ):
165+ # replace the name of the function by something unique
166+ func_evt = event ["func_evt_desc" ]
167+ func_evt = func_evt .replace (
168+ "def func_evt" , f"def { event ['name' ]} _func_evt"
169+ )
170+ event ["func_evt" ] = f"{ event ['name' ]} _func_evt"
171+ event ["func_evt_desc" ] = func_evt
172+ # otherwise assume it was defined in the global namespace
173+ # and just copy the function identifier
174+ else :
175+ event ["func_evt_desc" ] = event ["func_evt" ]
174176
177+ if "func_act" in event :
178+ # if the whole function in defined in the event, make sure it has a unique identifier
179+ if event ["func_act" ].startswith ("def" ):
180+ # replace the name of the function by something unique
181+ func_act = event ["func_act_desc" ]
182+ func_act = func_act .replace (
183+ "def func_act" , f"def { event ['name' ]} _func_act"
184+ )
185+ event ["func_act" ] = f"{ event ['name' ]} _func_act"
186+ event ["func_act_desc" ] = func_act
187+ # otherwise assume it was defined in the global namespace
188+ # and just copy the function identifier
189+ else :
190+ event ["func_act_desc" ] = event ["func_act" ]
175191 return data ["events" ]
176192
177193
0 commit comments