# Path: lib/cuckoo/common/objects.py
# class Dictionary(dict):
#     """Cuckoo custom dict."""
# 
#     def __getattr__(self, key):
#         return self.get(key, None)
# 
#     __setattr__ = dict.__setitem__
#     __delattr__ = dict.__delitem__


import os
import ConfigParser
from lib.cuckoo.common.constants import CUCKOO_ROOT
from lib.cuckoo.common.exceptions import CuckooOperationalError
from lib.cuckoo.common.objects import Dictionary
# Copyright (C) 2010-2015 Cuckoo Foundation.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.



class Config:
    """Configuration file parser."""

    def __init__(self, file_name="cuckoo", cfg=None):
        """
        @param file_name: file name without extension.
        @param cfg: configuration file path.
        """
        config = ConfigParser.ConfigParser()

        if cfg:
            config.read(cfg)
        else:
            config.read(os.path.join(CUCKOO_ROOT, "conf", "%s.conf" % file_name))

        for section in config.sections():

# Path: lib/cuckoo/common/objects.py
# class Dictionary(dict):
#     """Cuckoo custom dict."""
# 
#     def __getattr__(self, key):
#         return self.get(key, None)
# 
#     __setattr__ = dict.__setitem__
#     __delattr__ = dict.__delitem__


# Path: lib/cuckoo/common/config.py
import os
import ConfigParser
from lib.cuckoo.common.constants import CUCKOO_ROOT
from lib.cuckoo.common.exceptions import CuckooOperationalError
from lib.cuckoo.common.objects import Dictionary

# Copyright (C) 2010-2015 Cuckoo Foundation.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.



class Config:
    """Configuration file parser."""

    def __init__(self, file_name="cuckoo", cfg=None):
        """
        @param file_name: file name without extension.
        @param cfg: configuration file path.
        """
        config = ConfigParser.ConfigParser()

        if cfg:
            config.read(cfg)
        else:
            config.read(os.path.join(CUCKOO_ROOT, "conf", "%s.conf" % file_name))

        for section in config.sections():

            setattr(self, section, Dictionary())