# Path: cardinal/decorators.py
# def command(triggers):
#     if isinstance(triggers, str):
#         triggers = [triggers]
# 
#     if not isinstance(triggers, list):
#         raise TypeError("Command must be a trigger string or list of triggers")
# 
#     def wrap(f):
#         f.commands = triggers
#         return f
# 
#     return wrap
# 
# def help(lines):
#     # For backwards compatibility
#     if isinstance(lines, str):
#         lines = [lines]
# 
#     if not isinstance(lines, list):
#         raise TypeError("Help must be a help string or list of help strings")
# 
#     def wrap(f):
#         # Create help list or prepend to it
#         if not hasattr(f, 'help'):
#             f.help = lines
#         else:
#             f.help = lines + f.help
# 
#         return f
# 
#     return wrap


from datetime import datetime
from cardinal.decorators import command, help
                # Check if the command responds with the command the user
                # requested
                if hasattr(cmd, 'commands') and \
                        help_command in cmd.commands:
                    found_command = cmd
                    break

            # If the command was found and has a help file, set the help_text
            if found_command and hasattr(found_command, 'help'):
                help_text = found_command.help

            # Return the help text for the command found if it exists
            if found_command:
                return help_text

        # Didn't find the command, so return a command does not exist error
        return 'Command does not exist.'

    # Pulls relevant meta information from the Cardinal instance
    def _get_meta(self, cardinal):
        return {
            'uptime':  cardinal.uptime,
            'booted':  cardinal.booted,
        }

    # Given a number of seconds, converts it to a readable uptime string
    def _pretty_uptime(self, seconds):
        days, seconds = divmod(seconds, 60 * 60 * 24)
        hours, seconds = divmod(seconds, 60 * 60)
        minutes, seconds = divmod(seconds, 60)

# Path: cardinal/decorators.py
# def command(triggers):
#     if isinstance(triggers, str):
#         triggers = [triggers]
# 
#     if not isinstance(triggers, list):
#         raise TypeError("Command must be a trigger string or list of triggers")
# 
#     def wrap(f):
#         f.commands = triggers
#         return f
# 
#     return wrap
# 
# def help(lines):
#     # For backwards compatibility
#     if isinstance(lines, str):
#         lines = [lines]
# 
#     if not isinstance(lines, list):
#         raise TypeError("Help must be a help string or list of help strings")
# 
#     def wrap(f):
#         # Create help list or prepend to it
#         if not hasattr(f, 'help'):
#             f.help = lines
#         else:
#             f.help = lines + f.help
# 
#         return f
# 
#     return wrap


# Path: plugins/help/plugin.py
from datetime import datetime
from cardinal.decorators import command, help

                # Check if the command responds with the command the user
                # requested
                if hasattr(cmd, 'commands') and \
                        help_command in cmd.commands:
                    found_command = cmd
                    break

            # If the command was found and has a help file, set the help_text
            if found_command and hasattr(found_command, 'help'):
                help_text = found_command.help

            # Return the help text for the command found if it exists
            if found_command:
                return help_text

        # Didn't find the command, so return a command does not exist error
        return 'Command does not exist.'

    # Pulls relevant meta information from the Cardinal instance
    def _get_meta(self, cardinal):
        return {
            'uptime':  cardinal.uptime,
            'booted':  cardinal.booted,
        }

    # Given a number of seconds, converts it to a readable uptime string
    def _pretty_uptime(self, seconds):
        days, seconds = divmod(seconds, 60 * 60 * 24)
        hours, seconds = divmod(seconds, 60 * 60)
        minutes, seconds = divmod(seconds, 60)

        uptime = "%d days " % days if days else ""