# Path: statik/utils.py
# def underscore_var_names(d):
#     _d = {}
#     for k, v in d.items():
#         _k = k.replace('-', '_')
#         # perform the underscoring recursively
#         _d[_k] = underscore_var_names(v) if isinstance(v, dict) else v
# 
#     return _d


from copy import deepcopy, copy
from statik.utils import underscore_var_names
import logging
            static=None,
            dynamic=None,
            for_each=None
        ):
        self.initial = initial or dict()
        self.static = underscore_var_names(
            deepcopy(static or dict())
        )
        self.dynamic = underscore_var_names(
            deepcopy(dynamic or dict())
        )
        self.for_each = underscore_var_names(
            deepcopy(for_each or dict())
        )
        logger.debug("Created Statik context instance: %s", self)

    def __repr__(self):
        return "StatikContext(initial=%s, static=%s, dynamic=%s, for_each=%s)" % (
            self.initial, self.static, self.dynamic, self.for_each
        )

    def __str__(self):
        return repr(self)

    def build_dynamic(self, db, extra=None, safe_mode=False):
        """Builds the dynamic context based on our current dynamic context entity and the given
        database."""
        result = dict()
        for var, query in self.dynamic.items():
            result[var] = db.query(query, safe_mode=safe_mode, additional_locals=extra)

# Path: statik/utils.py
# def underscore_var_names(d):
#     _d = {}
#     for k, v in d.items():
#         _k = k.replace('-', '_')
#         # perform the underscoring recursively
#         _d[_k] = underscore_var_names(v) if isinstance(v, dict) else v
# 
#     return _d


# Path: statik/context.py
from copy import deepcopy, copy
from statik.utils import underscore_var_names
import logging

            static=None,
            dynamic=None,
            for_each=None
        ):
        self.initial = initial or dict()
        self.static = underscore_var_names(
            deepcopy(static or dict())
        )
        self.dynamic = underscore_var_names(
            deepcopy(dynamic or dict())
        )
        self.for_each = underscore_var_names(
            deepcopy(for_each or dict())
        )
        logger.debug("Created Statik context instance: %s", self)

    def __repr__(self):
        return "StatikContext(initial=%s, static=%s, dynamic=%s, for_each=%s)" % (
            self.initial, self.static, self.dynamic, self.for_each
        )

    def __str__(self):
        return repr(self)

    def build_dynamic(self, db, extra=None, safe_mode=False):
        """Builds the dynamic context based on our current dynamic context entity and the given
        database."""
        result = dict()
        for var, query in self.dynamic.items():
            result[var] = db.query(query, safe_mode=safe_mode, additional_locals=extra)

        return result