From f93db2a019430a7ae0aaed3823913a74697d84f1 Mon Sep 17 00:00:00 2001 From: Dylan Young Date: Sun, 8 Mar 2020 23:27:18 -0300 Subject: [PATCH] GH-36 rename policy_dict --- csp/decorators.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/csp/decorators.py b/csp/decorators.py index 61c085c..d7389d0 100644 --- a/csp/decorators.py +++ b/csp/decorators.py @@ -30,10 +30,10 @@ def _wrapped(*a, **kw): return decorator -def csp_update(csp_names=('default',), policy_dict=None, **kwargs): +def csp_update(csp_names=('default',), policy_definitions=None, **kwargs): update = _policies_from_names_and_kwargs( csp_names, - policy_dict, + policy_definitions, **kwargs, ) @@ -47,10 +47,10 @@ def _wrapped(*a, **kw): return decorator -def csp_replace(csp_names=('default',), policy_dict=None, **kwargs): +def csp_replace(csp_names=('default',), policy_definitions=None, **kwargs): replace = _policies_from_names_and_kwargs( csp_names, - policy_dict, + policy_definitions, **kwargs, ) @@ -64,7 +64,7 @@ def _wrapped(*a, **kw): return decorator -def csp(policies=(), policy_dict=None, **kwargs): +def csp(policies=(), policy_definitions=None, **kwargs): policies = iter_policies(tuple(policies)) if kwargs and not isinstance(next(iter(kwargs.values())), dict): @@ -72,23 +72,23 @@ def csp(policies=(), policy_dict=None, **kwargs): # TODO: single-policy format isn't currently supported for policy_dict policy_name = next(policy_names) - if policy_dict: - policy_dict[policy_name] = kwargs + if policy_definitions: + policy_definitions[policy_name] = kwargs else: - policy_dict = [(policy_name, kwargs)] - elif policy_dict: - duplicates = set(kwargs) & set(policy_dict) + policy_definitions = [(policy_name, kwargs)] + elif policy_definitions: + duplicates = set(kwargs) & set(policy_definitions) if duplicates: raise TypeError( # TypeError because python does it "csp decorator got multiple policy definitions " "for the same name: %s" % ', '.join(duplicates) ) - policy_dict.update(kwargs) + policy_definitions.update(kwargs) else: - policy_dict = kwargs + policy_definitions = kwargs config = OrderedDict(chain( - iter_policies(policy_dict), + iter_policies(policy_definitions), policies, )) # import pdb; pdb.set_trace()