# Path: imgfac/Notification.py
# class Notification(object):
#     """ TODO: Docstring for Notification  """
# 
#     message = prop("_message")
#     sender = prop("_sender")
#     user_info = prop("_user_info")
# 
#     def __init__(self, message, sender, user_info=None):
#         """ TODO: Fill me in
#         
#         @param message TODO
#         @param sender TODO
#         @param user_info TODO
#         """
#         self._message = message
#         self._sender = sender
#         self._user_info = user_info
# 
# Path: imgfac/NotificationCenter.py
# class NotificationCenter(Singleton):
#     """ TODO: Docstring for NotificationCenter  """
# 
#     observers = prop("_observers")
# 
#     def _singleton_init(self, *args, **kwargs):
#         self.log = logging.getLogger('%s.%s' % (__name__, self.__class__.__name__))
#         self.observers = defaultdict(set)
#         self.lock = RLock()
# 
#     def add_observer(self, observer, method, message='all', sender=None):
#         """
#         TODO: Docstring for add_observer
#         
#         @param observer TODO
#         @param method TODO
#         @param message TODO
#         @param sender TODO
#         """
#         self.lock.acquire()
#         self.observers[message].add((observer, method, sender))
#         self.lock.release()
# 
#     def remove_observer(self, observer, method, message='all', sender=None):
#         """
#         TODO: Docstring for remove_observer
#         
#         @param observer TODO
#         @param message TODO
#         @param sender TODO
#         """
#         self.lock.acquire()
#         _observer = (observer, method, sender)
#         self.observers[message].discard(_observer)
#         if (len(self.observers[message]) == 0):
#             del self.observers[message]
#         self.lock.release()
# 
#     def post_notification(self, notification):
#         """
#         TODO: Docstring for post_notification
#         
#         @param notification TODO
#         """
#         self.lock.acquire()
#         _observers = self.observers['all'].union(self.observers[notification.message])
#         for _observer in _observers:
#             _sender = _observer[2]
#             if ((not _sender) or (_sender == notification.sender)):
#                 try:
#                     getattr(_observer[0], _observer[1])(notification)
#                 except AttributeError as e:
#                     self.log.exception('Caught exception: posting notification to object (%s) with method (%s)' % (_observer[0], _observer[1]))
#         self.lock.release()
# 
#     def post_notification_with_info(self, message, sender, user_info=None):
#         """
#         TODO: Docstring for post_notification_with_info
#         
#         @param message TODO
#         @param sender TODO
#         @param user_info TODO
#         """
#         self.post_notification(Notification(message, sender, user_info))


from .props import prop
from .Notification import Notification
from .NotificationCenter import NotificationCenter
import uuid
import logging
NOTIFICATIONS = ('image.status', 'image.percentage')


class PersistentImage(object):
    """ TODO: Docstring for PersistentImage  """

##### PROPERTIES
    persistence_manager = prop("_persistence_manager")
    identifier = prop("_identifier")
    data = prop("_data")
    template = prop("_template")
    icicle = prop("_icicle")
    status_detail = prop("_status_detail")
    parameters = prop("_parameters")
    properties = prop("_properties")

    def status():
        doc = "A string value."

        def fget(self):
            return self._status

        def fset(self, value):
            value = value.upper()
            if value == self._status:
                # Do not update or send a notification if nothing has changed
                return
            if value in STATUS_STRINGS:
                old_value = self._status
                self._status = value

# Path: imgfac/Notification.py
# class Notification(object):
#     """ TODO: Docstring for Notification  """
# 
#     message = prop("_message")
#     sender = prop("_sender")
#     user_info = prop("_user_info")
# 
#     def __init__(self, message, sender, user_info=None):
#         """ TODO: Fill me in
#         
#         @param message TODO
#         @param sender TODO
#         @param user_info TODO
#         """
#         self._message = message
#         self._sender = sender
#         self._user_info = user_info
# 
# Path: imgfac/NotificationCenter.py
# class NotificationCenter(Singleton):
#     """ TODO: Docstring for NotificationCenter  """
# 
#     observers = prop("_observers")
# 
#     def _singleton_init(self, *args, **kwargs):
#         self.log = logging.getLogger('%s.%s' % (__name__, self.__class__.__name__))
#         self.observers = defaultdict(set)
#         self.lock = RLock()
# 
#     def add_observer(self, observer, method, message='all', sender=None):
#         """
#         TODO: Docstring for add_observer
#         
#         @param observer TODO
#         @param method TODO
#         @param message TODO
#         @param sender TODO
#         """
#         self.lock.acquire()
#         self.observers[message].add((observer, method, sender))
#         self.lock.release()
# 
#     def remove_observer(self, observer, method, message='all', sender=None):
#         """
#         TODO: Docstring for remove_observer
#         
#         @param observer TODO
#         @param message TODO
#         @param sender TODO
#         """
#         self.lock.acquire()
#         _observer = (observer, method, sender)
#         self.observers[message].discard(_observer)
#         if (len(self.observers[message]) == 0):
#             del self.observers[message]
#         self.lock.release()
# 
#     def post_notification(self, notification):
#         """
#         TODO: Docstring for post_notification
#         
#         @param notification TODO
#         """
#         self.lock.acquire()
#         _observers = self.observers['all'].union(self.observers[notification.message])
#         for _observer in _observers:
#             _sender = _observer[2]
#             if ((not _sender) or (_sender == notification.sender)):
#                 try:
#                     getattr(_observer[0], _observer[1])(notification)
#                 except AttributeError as e:
#                     self.log.exception('Caught exception: posting notification to object (%s) with method (%s)' % (_observer[0], _observer[1]))
#         self.lock.release()
# 
#     def post_notification_with_info(self, message, sender, user_info=None):
#         """
#         TODO: Docstring for post_notification_with_info
#         
#         @param message TODO
#         @param sender TODO
#         @param user_info TODO
#         """
#         self.post_notification(Notification(message, sender, user_info))


# Path: imgfac/PersistentImage.py
from .props import prop
from .Notification import Notification
from .NotificationCenter import NotificationCenter
import uuid
import logging

NOTIFICATIONS = ('image.status', 'image.percentage')


class PersistentImage(object):
    """ TODO: Docstring for PersistentImage  """

##### PROPERTIES
    persistence_manager = prop("_persistence_manager")
    identifier = prop("_identifier")
    data = prop("_data")
    template = prop("_template")
    icicle = prop("_icicle")
    status_detail = prop("_status_detail")
    parameters = prop("_parameters")
    properties = prop("_properties")

    def status():
        doc = "A string value."

        def fget(self):
            return self._status

        def fset(self, value):
            value = value.upper()
            if value == self._status:
                # Do not update or send a notification if nothing has changed
                return
            if value in STATUS_STRINGS:
                old_value = self._status
                self._status = value

                notification = Notification(message=NOTIFICATIONS[0],