File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed
Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change 11---
22name : napalm-ci_cd
33
4+ mgmt :
5+ network : clab_mgmt
6+ ipv4-subnet : 172.20.20.0/24
7+ ipv6-subnet : 2001:172:20:20::/64
8+
49topology :
510 kinds :
611 srl :
Original file line number Diff line number Diff line change @@ -2874,15 +2874,23 @@ def _decodeVal(self, val):
28742874 )
28752875
28762876 def _dictToList (self , aDict ):
2877- for key in aDict .keys ():
2877+ keys_to_update = {}
2878+ keys_to_delete = []
2879+
2880+ for key in list (aDict .keys ()): # Use list() to avoid modifying during iteration
28782881 if key .startswith ("___" ):
2879- aDict [key [3 :]] = [
2882+ keys_to_update [key [3 :]] = [
28802883 self ._dictToList (val ) if isinstance (val , dict ) else val
28812884 for val in aDict [key ].values ()
28822885 ]
2883- del aDict [key ]
2884- else :
2885- if isinstance (aDict [key ], dict ):
2886- aDict [key ] = self ._dictToList (aDict [key ])
2886+ keys_to_delete .append (key ) # Mark for deletion
2887+ elif isinstance (aDict [key ], dict ):
2888+ aDict [key ] = self ._dictToList (aDict [key ])
2889+
2890+ # Apply updates outside the loop
2891+ aDict .update (keys_to_update )
2892+ for key in keys_to_delete :
2893+ del aDict [key ]
2894+
28872895 return aDict
28882896
You can’t perform that action at this time.
0 commit comments