class Config(object):
    """
    The config class. Loads the config in the xml file passed
    and dynamically builds a structure based on this.
    """
    def __init__(self, configFile="config.xml", templates=None):
        """
        :type configFile: str
        :param configFile: The path to the config file
        :type templates: dict
        :param templates: The key values to substitute the templates in the config file
        """
        self.configFile = configFile
        self._LOCK = Lock()
        self._parser = XMLConfigurationParser()
        if templates is None:
            self._attr = self._parser.parse(configFile)
        else:
            self._attr = self._parser.parse(configFile, **templates)
        self._bck = self._attr

    @property
    def attr(self):
        return self._attr

    @attr.setter
    def attr(self, value):
        value = cgi.escape(value)
        with self._LOCK:
            self._attr = value

    @attr.getter
    def attr(self):
        with self._LOCK:
            return self._attr

    @property
    def bck(self):
        return None

    @bck.setter
    def bck(self, value):
        pass

    def reset(self):
        """
        Resets the config object to the default state, based on config,xml
        """
        self._attr = self._bck

    def reload(self):
        """
        Force the reload of the config.xml file
        """
        self._attr = self._parser.parse(self.configFile)
        self._bck = self._attr
class Config(object):
    def __init__(self):
        self._parser = XMLConfigurationParser()
        self._attr = self._parser.parse(os.path.join(self.getBasePath(), "config.xml"), BASEPATH=self.getBasePath())
        self._bck = self._attr

    def getBasePath(self):
        """
        Returns the project base path
        @rtype: str
        """
        path = os.path.dirname((os.path.dirname(os.path.abspath(__file__))))
        if not os.path.exists(path + "/"):
            #If compiled, the binarie is represented like a dir, so we must remove it
            path = re.sub(r'((/|\\)run-pygameoflife(.exe)?)', "", path).replace("/resource_manager.pyc", "")

        return path

    @property
    def attr(self):
        return self._attr

    @attr.setter
    def attr(self, value):
        self._attr = value

    @property
    def bck(self):
        return None

    @bck.setter
    def bck(self, value):
        pass

    def reset(self):
        """
        Resets the config object to the default state, based on config,xml
        """
        self._attr = self._bck

    def reload(self):
        """
        Force the reload of the config.xml file
        """
        self._attr = self._parser.parse("config.xml")
        self._bck = self._attr
 def __init__(self, configFile="config.xml", templates=None):
     """
     :type configFile: str
     :param configFile: The path to the config file
     :type templates: dict
     :param templates: The key values to substitute the templates in the config file
     """
     self.configFile = configFile
     self._LOCK = Lock()
     self._parser = XMLConfigurationParser()
     if templates is None:
         self._attr = self._parser.parse(configFile)
     else:
         self._attr = self._parser.parse(configFile, **templates)
     self._bck = self._attr
 def __init__(self):
     self._parser = XMLConfigurationParser()
     self._attr = self._parser.parse(os.path.join(self.getBasePath(), "config.xml"), BASEPATH=self.getBasePath())
     self._bck = self._attr