# Path: minette/serializer.py
# class Serializable:
#     """
#     Base class for serializable object
# 
#     """
# 
#     @classmethod
#     def _types(cls):
#         """
#         Override this method to create instance of specific class for members.
#         Configure like below then instance of `Foo` will be set to `self.foo`
#         and `Bar` to `self.bar`
#         ```
#         return {
#             "foo": Foo,
#             "bar": Bar
#         }
#         ```
#         """
#         return {}
# 
#     def __repr__(self):
#         return "<{} at {}>\n{}".format(
#             self.__class__.__name__,
#             hex(id(self)),
#             self.to_json(indent=2, ensure_ascii=False))
# 
#     @classmethod
#     def create_object(obj_cls, d):
#         return obj_cls()
# 
#     def to_dict(self):
#         """
#         Convert this object to dict
# 
#         Returns
#         -------
#         d : dict
#             Object as dict
#         """
#         return dumpd(self)
# 
#     def to_json(self, **kwargs):
#         """
#         Convert this object to JSON
# 
#         Returns
#         -------
#         s : str
#             Object as JSON string
#         """
#         return dumps(self, **kwargs)
# 
#     @classmethod
#     def from_dict(cls, d):
#         """
#         Create object from dict
# 
#         Parameters
#         ----------
#         d : dict
#             Dictionary of this object
# 
#         Returns
#         -------
#         obj : Serializable
#             Instance of this class
#         """
#         return loadd(d, cls)
# 
#     @classmethod
#     def from_dict_dict(cls, dict_dict):
#         """
#         Create dictionary of this objects from dictionaries of dictionaries
# 
#         Parameters
#         ----------
#         dict_dict : dict
#             Dictionary of dictionaries
# 
#         Returns
#         -------
#         dict_of_this_obj : dict
#             Dictionary of this objects
#         """
#         return {k: cls.from_dict(v) for k, v in dict_dict.items()}
# 
#     @classmethod
#     def from_json(cls, s, **kwargs):
#         """
#         Create this object from JSON string
# 
#         Parameters
#         ----------
#         s : str
#             JSON string of this object
# 
#         Returns
#         -------
#         obj : Serializable
#             Instance of this class
#         """
#         return loads(s, cls, **kwargs)
# 
# Path: minette/models/priority.py
# class Priority:
#     """
#     Priority of topic
# 
#     Attributes
#     ----------
#     Highest : int
#         Highest (100)
#     High : int
#         High (75)
#     Normal : int
#         Normal (50)
#     Low : int
#         Low (25)
#     Ignore : int
#         Ignore (0)
#     """
#     Highest = 100
#     High = 75
#     Normal = 50
#     Low = 25
#     Ignore = 0
# 
# Path: minette/models/topic.py
# class Topic(Serializable):
#     """
#     Topic
# 
#     Attributes
#     ----------
#     name : str
#         Name of topic
#     status : str
#         Status of topic
#     is_new : bool
#         True if topic starts at this turn
#     keep_on : bool
#         True to keep this topic at next turn
#     previous : minette.Topic
#         Previous topic object
#     priority : int
#         Priority of topic
#     is_changed : bool
#         True if topic is changed at this turn
#     """
#     def __init__(self):
#         self.name = ""
#         self.status = ""
#         self.is_new = False
#         self.keep_on = False
#         self.previous = None
#         self.priority = Priority.Normal
# 
#     @property
#     def is_changed(self):
#         if self.previous and self.previous.name == self.name:
#             return False
#         else:
#             return True


import traceback
from copy import deepcopy
from ..serializer import Serializable
from .priority import Priority
from .topic import Topic
        # backup previous topic
        self.topic.previous = None
        self.topic.previous = deepcopy(self.topic)
        # remove data if topic not keep_on
        if not self.topic.keep_on:
            self.topic.name = ""
            self.topic.status = ""
            self.topic.priority = Priority.Normal
            self.data = self.data if keep_data else {}
            self.error = {}

    def set_error(self, ex, info=None):
        """
        Set error info

        Parameters
        ----------
        ex : Exception
            Exception
        info : dict, default None
            More information for debugging
        """
        self.error = {
            "exception": str(ex),
            "traceback": traceback.format_exc(),
            "info": info if info else {}}

    @classmethod
    def _types(cls):
        return {

# Path: minette/serializer.py
# class Serializable:
#     """
#     Base class for serializable object
# 
#     """
# 
#     @classmethod
#     def _types(cls):
#         """
#         Override this method to create instance of specific class for members.
#         Configure like below then instance of `Foo` will be set to `self.foo`
#         and `Bar` to `self.bar`
#         ```
#         return {
#             "foo": Foo,
#             "bar": Bar
#         }
#         ```
#         """
#         return {}
# 
#     def __repr__(self):
#         return "<{} at {}>\n{}".format(
#             self.__class__.__name__,
#             hex(id(self)),
#             self.to_json(indent=2, ensure_ascii=False))
# 
#     @classmethod
#     def create_object(obj_cls, d):
#         return obj_cls()
# 
#     def to_dict(self):
#         """
#         Convert this object to dict
# 
#         Returns
#         -------
#         d : dict
#             Object as dict
#         """
#         return dumpd(self)
# 
#     def to_json(self, **kwargs):
#         """
#         Convert this object to JSON
# 
#         Returns
#         -------
#         s : str
#             Object as JSON string
#         """
#         return dumps(self, **kwargs)
# 
#     @classmethod
#     def from_dict(cls, d):
#         """
#         Create object from dict
# 
#         Parameters
#         ----------
#         d : dict
#             Dictionary of this object
# 
#         Returns
#         -------
#         obj : Serializable
#             Instance of this class
#         """
#         return loadd(d, cls)
# 
#     @classmethod
#     def from_dict_dict(cls, dict_dict):
#         """
#         Create dictionary of this objects from dictionaries of dictionaries
# 
#         Parameters
#         ----------
#         dict_dict : dict
#             Dictionary of dictionaries
# 
#         Returns
#         -------
#         dict_of_this_obj : dict
#             Dictionary of this objects
#         """
#         return {k: cls.from_dict(v) for k, v in dict_dict.items()}
# 
#     @classmethod
#     def from_json(cls, s, **kwargs):
#         """
#         Create this object from JSON string
# 
#         Parameters
#         ----------
#         s : str
#             JSON string of this object
# 
#         Returns
#         -------
#         obj : Serializable
#             Instance of this class
#         """
#         return loads(s, cls, **kwargs)
# 
# Path: minette/models/priority.py
# class Priority:
#     """
#     Priority of topic
# 
#     Attributes
#     ----------
#     Highest : int
#         Highest (100)
#     High : int
#         High (75)
#     Normal : int
#         Normal (50)
#     Low : int
#         Low (25)
#     Ignore : int
#         Ignore (0)
#     """
#     Highest = 100
#     High = 75
#     Normal = 50
#     Low = 25
#     Ignore = 0
# 
# Path: minette/models/topic.py
# class Topic(Serializable):
#     """
#     Topic
# 
#     Attributes
#     ----------
#     name : str
#         Name of topic
#     status : str
#         Status of topic
#     is_new : bool
#         True if topic starts at this turn
#     keep_on : bool
#         True to keep this topic at next turn
#     previous : minette.Topic
#         Previous topic object
#     priority : int
#         Priority of topic
#     is_changed : bool
#         True if topic is changed at this turn
#     """
#     def __init__(self):
#         self.name = ""
#         self.status = ""
#         self.is_new = False
#         self.keep_on = False
#         self.previous = None
#         self.priority = Priority.Normal
# 
#     @property
#     def is_changed(self):
#         if self.previous and self.previous.name == self.name:
#             return False
#         else:
#             return True


# Path: minette/models/context.py
import traceback
from copy import deepcopy
from ..serializer import Serializable
from .priority import Priority
from .topic import Topic

        # backup previous topic
        self.topic.previous = None
        self.topic.previous = deepcopy(self.topic)
        # remove data if topic not keep_on
        if not self.topic.keep_on:
            self.topic.name = ""
            self.topic.status = ""
            self.topic.priority = Priority.Normal
            self.data = self.data if keep_data else {}
            self.error = {}

    def set_error(self, ex, info=None):
        """
        Set error info

        Parameters
        ----------
        ex : Exception
            Exception
        info : dict, default None
            More information for debugging
        """
        self.error = {
            "exception": str(ex),
            "traceback": traceback.format_exc(),
            "info": info if info else {}}

    @classmethod
    def _types(cls):
        return {

            "topic": Topic