<commit_before>from taskwarrior_capsules import __version__
from taskwarrior_capsules.capsule import CommandCapsule
from taskwarrior_capsules.cmdline import get_installed_capsules
from taskwarrior_capsules.exceptions import CapsuleError


class Capsules(CommandCapsule):
    """ Capsule management utility """
    TASKWARRIOR_VERSION_CHECK_NECESSARY = False
    MIN_VERSION = __version__
    MAX_VERSION = __version__

    def handle(self, filter_args, extra_args, terminal=None, **kwargs):
        try:
            first_arg = extra_args[0].lower()
        except IndexError:
            raise CapsuleError("No context command specified")

        if first_arg == 'list':
            search_list = {
                'Installed Preprocessors': 'preprocessor',
                'Installed Commands': 'command',
                'Installed Postprocessors': 'postprocessor',
            }

            for headline, variant in search_list.items():
                print "{t.bold}{t.blue}{headline}{t.normal}:".format(
                    headline=headline,
                    t=terminal
                )
                for name, module in get_installed_capsules(variant).items():
                    summary = module.get_summary()
                    print "- {t.bold}{name}{t.normal}: {docstring}".format(
                        name=name,
                        t=terminal,
                        docstring=summary if summary else '(No docstring)'
                    )
                print ""
        else:
            raise CapsuleError("Command '%s' is not defined." % first_arg)<commit_msg>Release 1.0.0; updated to Python3, deprecated Python2.7<commit_after>from taskwarrior_capsules import __version__
from taskwarrior_capsules.capsule import CommandCapsule
from taskwarrior_capsules.cmdline import get_installed_capsules
from taskwarrior_capsules.exceptions import CapsuleError


class Capsules(CommandCapsule):
    """ Capsule management utility """
    TASKWARRIOR_VERSION_CHECK_NECESSARY = False
    MIN_VERSION = __version__
    MAX_VERSION = __version__

    def handle(self, filter_args, extra_args, terminal=None, **kwargs):
        try:
            first_arg = extra_args[0].lower()
        except IndexError:
            raise CapsuleError("No context command specified")

        if first_arg == 'list':
            search_list = {
                'Installed Preprocessors': 'preprocessor',
                'Installed Commands': 'command',
                'Installed Postprocessors': 'postprocessor',
            }

            for headline, variant in search_list.items():
                print(f'{terminal.bold}{terminal.blue}{headline}{terminal.normal}:')

                for name, module in get_installed_capsules(variant).items():
                    summary = module.get_summary()
                    print(f'- {terminal.bold}{name}{terminal.normal}: {summary if summary else "(No docstring)"}')
                print("")
        else:
            raise CapsuleError("Command '%s' is not defined." % first_arg)
{'fraction_non_alphanumeric': 0.0911784068466096, 'fraction_numerical': 0.0026333113890717576, 'mean_word_length': 2.292524377031419, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '114540', 'n_tokens_mistral': 830, 'n_tokens_neox': 784, 'n_words': 183}