# Path: pisi/util.py
# class Singleton(type):
#     def __init__(cls, name, bases, dict):
#         super(Singleton, cls).__init__(name, bases, dict)
#         cls.instance = None
# 
#     def __call__(cls, *args, **kw):
#         if cls.instance is None:
#             cls.instance = super(Singleton, cls).__call__(*args, **kw)
# 
#         return cls.instance


import gettext
from pisi.util import Singleton

class _constant:
    "Constant members implementation"
    class ConstError(TypeError):
        pass

    def __setattr__(self, name, value):
        if self.__dict__.has_key(name):
            raise self.ConstError, _("Can't rebind constant: %s") % name
        # Binding an attribute once to a const is available
        self.__dict__[name] = value

    def __delattr__(self, name):
        if self.__dict__.has_key(name):
            raise self.ConstError, _("Can't unbind constant: %s") % name
        # we don't have an attribute by this name
        raise NameError, name

class Constants:
    "Pisi Constants Singleton"

    __metaclass__ = Singleton

    __c = _constant()

    def __init__(self):
        # suffix for package names
        self.__c.package_suffix = ".pisi"

        # delta suffix for package names

# Path: pisi/util.py
# class Singleton(type):
#     def __init__(cls, name, bases, dict):
#         super(Singleton, cls).__init__(name, bases, dict)
#         cls.instance = None
# 
#     def __call__(cls, *args, **kw):
#         if cls.instance is None:
#             cls.instance = super(Singleton, cls).__call__(*args, **kw)
# 
#         return cls.instance


# Path: pisi/constants.py
import gettext
from pisi.util import Singleton


class _constant:
    "Constant members implementation"
    class ConstError(TypeError):
        pass

    def __setattr__(self, name, value):
        if self.__dict__.has_key(name):
            raise self.ConstError, _("Can't rebind constant: %s") % name
        # Binding an attribute once to a const is available
        self.__dict__[name] = value

    def __delattr__(self, name):
        if self.__dict__.has_key(name):
            raise self.ConstError, _("Can't unbind constant: %s") % name
        # we don't have an attribute by this name
        raise NameError, name

class Constants:
    "Pisi Constants Singleton"

    __metaclass__ = Singleton

    __c = _constant()

    def __init__(self):
        # suffix for package names
        self.__c.package_suffix = ".pisi"

        # delta suffix for package names

        self.__c.delta_package_suffix = ".delta.pisi"