# Path: clearstack/group.py
# class Group(object):
#     def __init__(self, group_name, arguments):
#         self.group_name = group_name
#         self.arguments = arguments
# 
#     def get_group_name(self):
#         return self.group_name
# 
#     def get_all_arguments(self):
#         return self.arguments
# 
# Path: clearstack/sequence.py
# class Sequence:
#     def __init__(self, desc, function, args=None):
#         self.description = desc
#         self.function = function
#         self.function_args = args
# 
#     def run(self):
#         LOG.info(self.description)
#         if self.function_args:
#             if not self.function(*self.function_args):
#                 raise Exception("error running {0}({1})"
#                                 .format(self.function.__name__,
#                                         self.function_args))
#         else:
#             if not self.function():
#                 raise Exception("error running {0}"
#                                 .format(self.function.__name__))
# 
# Path: clearstack/common/singleton.py
# class Singleton:
#     def __init__(self, decorated):
#         self._decorated = decorated
# 
#     def get(self):
#         try:
#             return self._instance
#         except AttributeError:
#             self._instance = self._decorated()
#             return self._instance
# 
#     def __call__(self):
#         raise TypeError('Singletons must be accessed through `Get()`.')
# 
#     def __instancecheck__(self, inst):
#         return isinstance(inst, self._decorated)


from clearstack.group import Group
from clearstack.sequence import Sequence
from clearstack.common.singleton import Singleton
#


DEBUG = False


@Singleton
class Controller:
    CONF = {}
    _plugins = []
    _groups = []
    _sequences = []

    def add_sequence(self, desc, function, args=None):
        self._sequences.append(Sequence(desc, function, args))

    def run_all_sequences(self):
        for seq in self._sequences:
            try:
                seq.run()
            except Exception as e:
                raise e

    def add_plugin(self, plugin):
        self._plugins.append(plugin)

    def get_all_plugins(self):
        return self._plugins

    def add_group(self, name, args):

# Path: clearstack/group.py
# class Group(object):
#     def __init__(self, group_name, arguments):
#         self.group_name = group_name
#         self.arguments = arguments
# 
#     def get_group_name(self):
#         return self.group_name
# 
#     def get_all_arguments(self):
#         return self.arguments
# 
# Path: clearstack/sequence.py
# class Sequence:
#     def __init__(self, desc, function, args=None):
#         self.description = desc
#         self.function = function
#         self.function_args = args
# 
#     def run(self):
#         LOG.info(self.description)
#         if self.function_args:
#             if not self.function(*self.function_args):
#                 raise Exception("error running {0}({1})"
#                                 .format(self.function.__name__,
#                                         self.function_args))
#         else:
#             if not self.function():
#                 raise Exception("error running {0}"
#                                 .format(self.function.__name__))
# 
# Path: clearstack/common/singleton.py
# class Singleton:
#     def __init__(self, decorated):
#         self._decorated = decorated
# 
#     def get(self):
#         try:
#             return self._instance
#         except AttributeError:
#             self._instance = self._decorated()
#             return self._instance
# 
#     def __call__(self):
#         raise TypeError('Singletons must be accessed through `Get()`.')
# 
#     def __instancecheck__(self, inst):
#         return isinstance(inst, self._decorated)


# Path: clearstack/controller.py
from clearstack.group import Group
from clearstack.sequence import Sequence
from clearstack.common.singleton import Singleton

#


DEBUG = False


@Singleton
class Controller:
    CONF = {}
    _plugins = []
    _groups = []
    _sequences = []

    def add_sequence(self, desc, function, args=None):
        self._sequences.append(Sequence(desc, function, args))

    def run_all_sequences(self):
        for seq in self._sequences:
            try:
                seq.run()
            except Exception as e:
                raise e

    def add_plugin(self, plugin):
        self._plugins.append(plugin)

    def get_all_plugins(self):
        return self._plugins

    def add_group(self, name, args):

        self._groups.append(Group(name, args))