Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/defence360agent/internals/global_scope.py
import logging

logger = logging.getLogger(__name__)


class GlobalScope(dict):
    def __getattr__(self, item):
        try:
            return self[item]
        except KeyError as err:
            raise AttributeError(f"{item} is not in global scope") from err

    def __setattr__(self, key, value):
        if key in self:
            logger.warning("Name %s is already in global scope", key)
        else:
            self[key] = value


g = GlobalScope()