# coding: utf-8

from __future__ import division, unicode_literals

"""
This module defines some useful design patterns.
"""


__author__ = "Shyue Ping Ong"
__copyright__ = "Copyright 2011, The Materials Project"
__version__ = "1.0"
__maintainer__ = "Shyue Ping Ong"
__email__ = "shyuep@gmail.com"
__status__ = "Production"
__date__ = "Sep 23, 2011"


class Enum(set):
    """
    Creates an enum out of a set.
    """
    def __getattr__(self, name):
        if name in self:
            return name
        raise AttributeError


class NullFile(object):
    """A file object that is associated to /dev/null."""
    def __new__(cls):
        import os
        return open(os.devnull, 'w')

    def __init__(self):
        """no-op"""


class NullStream(object):
    """A fake stream with a no-op write.."""
    def write(*args):
        """no-op"""


# coding: utf-8

from __future__ import division, unicode_literals

"""
This module defines some useful design patterns.
"""


__author__ = "Shyue Ping Ong"
__copyright__ = "Copyright 2011, The Materials Project"
__version__ = "1.0"
__maintainer__ = "Shyue Ping Ong"
__email__ = "shyuep@gmail.com"
__status__ = "Production"
__date__ = "Sep 23, 2011"


class Enum(set):
    """
    Creates an enum out of a set.
    """
    def __getattr__(self, name):
        if name in self:
            return name
        raise AttributeError


Move NullFile and NullStream to monty
Move NullFile and NullStream to monty


Former-commit-id: 5492c3519fdfc444fd8cbb92cbf4b9c67c8a0883 [formerly 4aa6714284cb45a2747cea8e0f38e8fbcd8ec0bc]
Former-commit-id: e6119512027c605a8277d0a99f37a6ab0d73b6c7