# Path: karmabot/core/storage.py
# def load_catalog(sender):
#     def __init__(self, host='localhost', port=6379, db=0):
#     def __len__(self):
#     def get(self, key):
#     def set(self, key, value):
# class Catalog(dict):


import re
from karmabot.core import storage
                instance = None
                match_group = match.groupdict()
                subject = match_group.get('subject', None)
                command = command_info['command']
                match_group.update({'context': context})

                if subject:
                    match_group.update(
                        {'subject': storage.db.get(subject)})
                    handler_cls = command.handler.__module__.split('.').pop()
                    instance = match_group['subject'].facets.get(handler_cls)

                substitution = self.dispatch_command(command,
                                                     instance, match_group)
                handled = True
                if substitution:
                    # Start over with the new string
                    newtext = ''.join([text[:match.start()], substitution,
                                      text[match.end():]])
                    return self.handle_command(newtext, context, True)

                if command_info["exclusive"]:
                    break
        return (handled, text)

    def dispatch_command(self, command, instance, kw):
        if instance:
            context = kw.get('context')
            command.handler(instance, **kw)
            if context:

# Path: karmabot/core/storage.py
# def load_catalog(sender):
#     def __init__(self, host='localhost', port=6379, db=0):
#     def __len__(self):
#     def get(self, key):
#     def set(self, key, value):
# class Catalog(dict):


# Path: karmabot/core/commands/command.py
import re
from karmabot.core import storage

                instance = None
                match_group = match.groupdict()
                subject = match_group.get('subject', None)
                command = command_info['command']
                match_group.update({'context': context})

                if subject:
                    match_group.update(
                        {'subject': storage.db.get(subject)})
                    handler_cls = command.handler.__module__.split('.').pop()
                    instance = match_group['subject'].facets.get(handler_cls)

                substitution = self.dispatch_command(command,
                                                     instance, match_group)
                handled = True
                if substitution:
                    # Start over with the new string
                    newtext = ''.join([text[:match.start()], substitution,
                                      text[match.end():]])
                    return self.handle_command(newtext, context, True)

                if command_info["exclusive"]:
                    break
        return (handled, text)

    def dispatch_command(self, command, instance, kw):
        if instance:
            context = kw.get('context')
            command.handler(instance, **kw)
            if context:

                storage.db.set(instance.subject.key,