Limit deepcopy to just the initial "all" section (#37718)
Modifications: - [x] Limit the scope of the deepcopy when initializing module file writers
This commit is contained in:
parent
bcb7af6eb3
commit
d45818ccff
@ -170,17 +170,12 @@ def merge_config_rules(configuration, spec):
|
|||||||
Returns:
|
Returns:
|
||||||
dict: actions to be taken on the spec passed as an argument
|
dict: actions to be taken on the spec passed as an argument
|
||||||
"""
|
"""
|
||||||
|
# Construct a dictionary with the actions we need to perform on the spec passed as a parameter
|
||||||
# Get the top-level configuration for the module type we are using
|
spec_configuration = {}
|
||||||
module_specific_configuration = copy.deepcopy(configuration)
|
|
||||||
|
|
||||||
# Construct a dictionary with the actions we need to perform on the spec
|
|
||||||
# passed as a parameter
|
|
||||||
|
|
||||||
# The keyword 'all' is always evaluated first, all the others are
|
# The keyword 'all' is always evaluated first, all the others are
|
||||||
# evaluated in order of appearance in the module file
|
# evaluated in order of appearance in the module file
|
||||||
spec_configuration = module_specific_configuration.pop("all", {})
|
spec_configuration.update(copy.deepcopy(configuration.get("all", {})))
|
||||||
for constraint, action in module_specific_configuration.items():
|
for constraint, action in configuration.items():
|
||||||
if spec.satisfies(constraint):
|
if spec.satisfies(constraint):
|
||||||
if hasattr(constraint, "override") and constraint.override:
|
if hasattr(constraint, "override") and constraint.override:
|
||||||
spec_configuration = {}
|
spec_configuration = {}
|
||||||
@ -200,14 +195,14 @@ def merge_config_rules(configuration, spec):
|
|||||||
# configuration
|
# configuration
|
||||||
|
|
||||||
# Hash length in module files
|
# Hash length in module files
|
||||||
hash_length = module_specific_configuration.get("hash_length", 7)
|
hash_length = configuration.get("hash_length", 7)
|
||||||
spec_configuration["hash_length"] = hash_length
|
spec_configuration["hash_length"] = hash_length
|
||||||
|
|
||||||
verbose = module_specific_configuration.get("verbose", False)
|
verbose = configuration.get("verbose", False)
|
||||||
spec_configuration["verbose"] = verbose
|
spec_configuration["verbose"] = verbose
|
||||||
|
|
||||||
# module defaults per-package
|
# module defaults per-package
|
||||||
defaults = module_specific_configuration.get("defaults", [])
|
defaults = configuration.get("defaults", [])
|
||||||
spec_configuration["defaults"] = defaults
|
spec_configuration["defaults"] = defaults
|
||||||
|
|
||||||
return spec_configuration
|
return spec_configuration
|
||||||
|
Loading…
Reference in New Issue
Block a user