Skip to content

Commit

Permalink
Fix 'dictionary keys changed during iteration' error
Browse files Browse the repository at this point in the history
  • Loading branch information
vjf authored Jul 22, 2024
1 parent c54b1a1 commit 768b576
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scripts/lib/config_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
from collections import defaultdict
from pathlib import PurePath
from copy import deepcopy

# Set up debugging
LOCAL_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -131,12 +132,15 @@ def create_json_config(self, output_filename, dest_dir, params):

# Are there any group names to be renamed?
if hasattr(params, 'grp_rename_list'):
grp_clone = deepcopy(config_dict['groups'])
for from_name, to_name in params.grp_rename_list:
for grp in config_dict['groups']:
# Case insensitive compare
if grp.casefold() == from_name.casefold():
LOCAL_LOGGER.debug(f"Renaming group labels: {to_name} renamed to {from_name}")
config_dict['groups'][to_name] = config_dict['groups'].pop(grp)
grp_clone[to_name] = grp_clone.pop(grp)
break
config_dict['groups'] = grp_clone

# Is there a proj4 definition?
if hasattr(params, 'proj4_defn'):
Expand Down

0 comments on commit 768b576

Please sign in to comment.