# Path: cydra/component.py
# class Interface(object):
#     """Marker base class for extension point interfaces.
# 
#     Behavior of the ExtensionPoints for an interface can be customized with
#     _iface_XY class attributes. These behaviors are specified in the interface
#     in order to establish common ground rules in accessing the components for
#     an interface."""
# 
#     _iface_single_extension = False
#     """Only allow one active component for this interface"""
# 
#     _iface_attribute_proxy = None
#     """Callable to use for attribute access
# 
#     The callable will receive the paramenters interface, components and name (in this order)"""
# 
#     _iface_disable_extension_cache = False
#     """Disable the cache for the active extensions"""
# 
# class BroadcastAttributeProxy(object):
#     """Proxy for use in interfaces
# 
#     Calls all extensions and returns a list with the results"""
# 
#     def __init__(self, merge_lists=False):
#         """Init BroadcastAttributeProxy
# 
#         :param merge_lists: Consider return values to be lists and merge them into a single list"""
#         self.merge_lists = merge_lists
# 
#     def __call__(self, interface, components, name):
#         def call_all_components(*args, **kwargs):
#             return self.post_process([getattr(o, name)(*args, **kwargs) for o in components if hasattr(o, name)])
# 
#         if callable(getattr(interface, name)):
#             return call_all_components
#         else:
#             return self.post_process([getattr(o, name) for o in components if hasattr(o, name)])
# 
#     def post_process(self, result):
#         if self.merge_lists:
#             res = []
#             for l in result:
#                 if l is None:
#                     continue
#                 if isinstance(l, list):
#                     res.extend(l)
#                 else:
#                     res.append(l)
#             result = res
#         return result


from cydra.component import Interface, BroadcastAttributeProxy
#
# You should have received a copy of the GNU General Public License
# along with Cydra.  If not, see http://www.gnu.org/licenses


class IRepositoryViewerProvider(Interface):

    _iface_attribute_proxy = BroadcastAttributeProxy()

    def get_repository_viewers(self, repository):
        """Provide URLs for repository viewer
        
        :returns: A list of ('name', 'url') tuples or a single one"""
        pass

class IRepositoryActionProvider(Interface):

    _iface_attribute_proxy = BroadcastAttributeProxy()

    def get_repository_actions(self, repository):
        """Provide endpoints for repository actions
        
        The method can either be get or post, depending on if the action
        has side effects.
        
        :returns: A list of ('name', 'endpoint', 'method') tuples or a single one"""
        pass

class IProjectActionProvider(Interface):


# Path: cydra/component.py
# class Interface(object):
#     """Marker base class for extension point interfaces.
# 
#     Behavior of the ExtensionPoints for an interface can be customized with
#     _iface_XY class attributes. These behaviors are specified in the interface
#     in order to establish common ground rules in accessing the components for
#     an interface."""
# 
#     _iface_single_extension = False
#     """Only allow one active component for this interface"""
# 
#     _iface_attribute_proxy = None
#     """Callable to use for attribute access
# 
#     The callable will receive the paramenters interface, components and name (in this order)"""
# 
#     _iface_disable_extension_cache = False
#     """Disable the cache for the active extensions"""
# 
# class BroadcastAttributeProxy(object):
#     """Proxy for use in interfaces
# 
#     Calls all extensions and returns a list with the results"""
# 
#     def __init__(self, merge_lists=False):
#         """Init BroadcastAttributeProxy
# 
#         :param merge_lists: Consider return values to be lists and merge them into a single list"""
#         self.merge_lists = merge_lists
# 
#     def __call__(self, interface, components, name):
#         def call_all_components(*args, **kwargs):
#             return self.post_process([getattr(o, name)(*args, **kwargs) for o in components if hasattr(o, name)])
# 
#         if callable(getattr(interface, name)):
#             return call_all_components
#         else:
#             return self.post_process([getattr(o, name) for o in components if hasattr(o, name)])
# 
#     def post_process(self, result):
#         if self.merge_lists:
#             res = []
#             for l in result:
#                 if l is None:
#                     continue
#                 if isinstance(l, list):
#                     res.extend(l)
#                 else:
#                     res.append(l)
#             result = res
#         return result


# Path: cydra/web/frontend/hooks.py
from cydra.component import Interface, BroadcastAttributeProxy

#
# You should have received a copy of the GNU General Public License
# along with Cydra.  If not, see http://www.gnu.org/licenses


class IRepositoryViewerProvider(Interface):

    _iface_attribute_proxy = BroadcastAttributeProxy()

    def get_repository_viewers(self, repository):
        """Provide URLs for repository viewer
        
        :returns: A list of ('name', 'url') tuples or a single one"""
        pass

class IRepositoryActionProvider(Interface):

    _iface_attribute_proxy = BroadcastAttributeProxy()

    def get_repository_actions(self, repository):
        """Provide endpoints for repository actions
        
        The method can either be get or post, depending on if the action
        has side effects.
        
        :returns: A list of ('name', 'endpoint', 'method') tuples or a single one"""
        pass

class IProjectActionProvider(Interface):


    _iface_attribute_proxy = BroadcastAttributeProxy()