@@ -314,33 +314,31 @@ def maybe_split_groups(self, max_groups):
314314 :param max_groups: Max group list size
315315 :return: True if at least one command was split, False if none were split
316316 """
317- new_commands = []
317+ split_commands = []
318318 # return True if we split at least once
319319 maybe_split = False
320320 valid_step_keys = ['add' , 'addRoles' , 'remove' ]
321321 for command in self .commands :
322322 # commands are assumed to contain a single key
323323 step_key , step_args = next (six .iteritems (command ))
324- if step_key not in valid_step_keys :
325- new_commands .append (command )
324+ if step_key not in valid_step_keys or not isinstance ( step_args , dict ) :
325+ split_commands .append (command )
326326 continue
327- split_commands = [command ]
327+ new_commands = [command ]
328328 while True :
329329 new_command = {step_key : {}}
330- if not isinstance (command [step_key ], dict ):
331- break
332330 for group_type , groups in six .iteritems (command [step_key ]):
333331 if len (groups ) > max_groups :
334- maybe_split = True
335332 command [step_key ][group_type ], new_command [step_key ][group_type ] = \
336333 groups [0 :max_groups ], groups [max_groups :]
337334 if new_command [step_key ]:
338- split_commands .append (new_command )
335+ new_commands .append (new_command )
339336 command = new_command
337+ maybe_split = True
340338 else :
341339 break
342- new_commands += split_commands
343- self .commands = new_commands
340+ split_commands += new_commands
341+ self .commands = split_commands
344342 return maybe_split
345343
346344
0 commit comments