# Path: cuwo/types.py
# class AttributeSet(set):
#     """
#     set with attribute access, i.e.
# 
#         foo = AttributeSet()
#         foo.bar = True
#         foo.bar == 'bar' in foo == True
#         foo.bar = False
#         foo.bar == 'bar' in foo == False
# 
#     This works as a quick shorthand for membership testing.
#     """
# 
#     def __getattr__(self, name):
#         return name in self
# 
#     def __setattr__(self, name, value):
#         if value:
#             self.add(name)
#         else:
#             self.discard(name)
# 
# class AttributeDict(dict):
#     """
#     dict with attribute access
#     """
#     def __init__(self, *args, **kw):
#         super(AttributeDict, self).__init__(*args, **kw)
#         self.__dict__ = self


from cuwo.types import AttributeSet, AttributeDict
import collections
import sys
import inspect
            import traceback
        command = self.commands.get(command, None)
        if not command:
            return
        user.parent = self  # for ScriptInterface

        if len(args) < command.min_args:
            return command.get_syntax()
        if command.max_args is not None and len(args) > command.max_args:
            return command.get_syntax()

        try:
            ret = command(user, *args) or ''
        except InvalidPlayer:
            ret = 'Invalid player specified'
        except InsufficientRights:
            ret = 'Insufficient rights'
        except Exception:
            traceback.print_exc()
            ret = ''
        return ret


class ScriptInterface:
    """
    Used for external script interfaces to emulate a connection for e.g.
    console and IRC commands
    """

    def __init__(self, name, server, *rights):
        self.name = name

# Path: cuwo/types.py
# class AttributeSet(set):
#     """
#     set with attribute access, i.e.
# 
#         foo = AttributeSet()
#         foo.bar = True
#         foo.bar == 'bar' in foo == True
#         foo.bar = False
#         foo.bar == 'bar' in foo == False
# 
#     This works as a quick shorthand for membership testing.
#     """
# 
#     def __getattr__(self, name):
#         return name in self
# 
#     def __setattr__(self, name, value):
#         if value:
#             self.add(name)
#         else:
#             self.discard(name)
# 
# class AttributeDict(dict):
#     """
#     dict with attribute access
#     """
#     def __init__(self, *args, **kw):
#         super(AttributeDict, self).__init__(*args, **kw)
#         self.__dict__ = self


# Path: cuwo/script.py
from cuwo.types import AttributeSet, AttributeDict
import collections
import sys
import inspect
            import traceback

        command = self.commands.get(command, None)
        if not command:
            return
        user.parent = self  # for ScriptInterface

        if len(args) < command.min_args:
            return command.get_syntax()
        if command.max_args is not None and len(args) > command.max_args:
            return command.get_syntax()

        try:
            ret = command(user, *args) or ''
        except InvalidPlayer:
            ret = 'Invalid player specified'
        except InsufficientRights:
            ret = 'Insufficient rights'
        except Exception:
            traceback.print_exc()
            ret = ''
        return ret


class ScriptInterface:
    """
    Used for external script interfaces to emulate a connection for e.g.
    console and IRC commands
    """

    def __init__(self, name, server, *rights):
        self.name = name

        self.rights = AttributeSet(rights)