# Path: zfs_autobackup/CachedProperty.py
# class CachedProperty(object):
#     """ A property that is only computed once per instance and
#     then stores the result in _cached_properties of the object.
# 
#         Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
#         """
# 
#     def __init__(self, func):
#         self.__doc__ = getattr(func, '__doc__')
#         self.func = func
# 
#     def __get__(self, obj, cls):
#         if obj is None:
#             return self
# 
#         propname = self.func.__name__
# 
#         if not hasattr(obj, '_cached_properties'):
#             obj._cached_properties = {}
# 
#         if propname not in obj._cached_properties:
#             obj._cached_properties[propname] = self.func(obj)
#             # value = obj.__dict__[propname] = self.func(obj)
# 
#         return obj._cached_properties[propname]
# 
#     @staticmethod
#     def clear(obj):
#         """clears cache of obj"""
#         if hasattr(obj, '_cached_properties'):
#             obj._cached_properties = {}
# 
#     @staticmethod
#     def is_cached(obj, propname):
#         if hasattr(obj, '_cached_properties') and propname in obj._cached_properties:
#             return True
#         else:
#             return False


from .CachedProperty import CachedProperty
    """a zfs pool"""

    def __init__(self, zfs_node, name):
        """name: name of the pool
        """

        self.zfs_node = zfs_node
        self.name = name

    def __repr__(self):
        return "{}: {}".format(self.zfs_node, self.name)

    def __str__(self):
        return self.name

    def __eq__(self, obj):
        if not isinstance(obj, ZfsPool):
            return False

        return self.name == obj.name

    def verbose(self, txt):
        self.zfs_node.verbose("zpool {}: {}".format(self.name, txt))

    def error(self, txt):
        self.zfs_node.error("zpool {}: {}".format(self.name, txt))

    def debug(self, txt):
        self.zfs_node.debug("zpool {}: {}".format(self.name, txt))


# Path: zfs_autobackup/CachedProperty.py
# class CachedProperty(object):
#     """ A property that is only computed once per instance and
#     then stores the result in _cached_properties of the object.
# 
#         Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
#         """
# 
#     def __init__(self, func):
#         self.__doc__ = getattr(func, '__doc__')
#         self.func = func
# 
#     def __get__(self, obj, cls):
#         if obj is None:
#             return self
# 
#         propname = self.func.__name__
# 
#         if not hasattr(obj, '_cached_properties'):
#             obj._cached_properties = {}
# 
#         if propname not in obj._cached_properties:
#             obj._cached_properties[propname] = self.func(obj)
#             # value = obj.__dict__[propname] = self.func(obj)
# 
#         return obj._cached_properties[propname]
# 
#     @staticmethod
#     def clear(obj):
#         """clears cache of obj"""
#         if hasattr(obj, '_cached_properties'):
#             obj._cached_properties = {}
# 
#     @staticmethod
#     def is_cached(obj, propname):
#         if hasattr(obj, '_cached_properties') and propname in obj._cached_properties:
#             return True
#         else:
#             return False


# Path: zfs_autobackup/ZfsPool.py
from .CachedProperty import CachedProperty

    """a zfs pool"""

    def __init__(self, zfs_node, name):
        """name: name of the pool
        """

        self.zfs_node = zfs_node
        self.name = name

    def __repr__(self):
        return "{}: {}".format(self.zfs_node, self.name)

    def __str__(self):
        return self.name

    def __eq__(self, obj):
        if not isinstance(obj, ZfsPool):
            return False

        return self.name == obj.name

    def verbose(self, txt):
        self.zfs_node.verbose("zpool {}: {}".format(self.name, txt))

    def error(self, txt):
        self.zfs_node.error("zpool {}: {}".format(self.name, txt))

    def debug(self, txt):
        self.zfs_node.debug("zpool {}: {}".format(self.name, txt))


    @CachedProperty