# Path: pytrainer/platform.py
# def get_platform():
#     if os.name == "posix":
#         return _Linux() #although not true, not changing original return name to avoid side effects
#     elif os.name == "nt":
#         return _Windows()
#     else:
#         logging.critical("Unsupported os.name: %s.", os.name)
#         sys.exit(1)
# 
# Path: pytrainer/lib/singleton.py
# class Singleton (object):
#     def __new__(cls, *args, **kwargs): 
#         if not hasattr(cls, 'self'):
#             cls.self = object.__new__(cls)
#         return cls.self


import os
from pytrainer.platform import get_platform
from pytrainer.lib.singleton import Singleton
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


class Environment(Singleton):
    
    """Describes the location of the program's configuration directories and files."""
    
    def __init__(self, conf_dir=None, data_path=None):
        """Initialise an environment.
        
        Arguments:
        conf_dir -- the directory where program configuration should be stored. If None, then the default for the platform is used.
        
        """
        if not hasattr(self, 'conf_dir'):
            if conf_dir:
                self.conf_dir = conf_dir
            else:

# Path: pytrainer/platform.py
# def get_platform():
#     if os.name == "posix":
#         return _Linux() #although not true, not changing original return name to avoid side effects
#     elif os.name == "nt":
#         return _Windows()
#     else:
#         logging.critical("Unsupported os.name: %s.", os.name)
#         sys.exit(1)
# 
# Path: pytrainer/lib/singleton.py
# class Singleton (object):
#     def __new__(cls, *args, **kwargs): 
#         if not hasattr(cls, 'self'):
#             cls.self = object.__new__(cls)
#         return cls.self


# Path: pytrainer/environment.py
import os
from pytrainer.platform import get_platform
from pytrainer.lib.singleton import Singleton

#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


class Environment(Singleton):
    
    """Describes the location of the program's configuration directories and files."""
    
    def __init__(self, conf_dir=None, data_path=None):
        """Initialise an environment.
        
        Arguments:
        conf_dir -- the directory where program configuration should be stored. If None, then the default for the platform is used.
        
        """
        if not hasattr(self, 'conf_dir'):
            if conf_dir:
                self.conf_dir = conf_dir
            else:

                self.conf_dir = get_platform().get_default_conf_dir()