<commit_before>__author__ = 'maroun'


import os

from nose.plugins import Plugin


class DocString(Plugin):
    """
    This plugin enables you to display attributes next to the original
    docstring.

    Usage example:
         > python main.py --with-docstring --prefix=platform,id --suffix=type
    """

    args = dict()
    prefix_info = list()
    suffix_info = list()

    def describeTest(self, running_test):
        keywords = running_test.test.__dict__['test'].keywords

        for prefix in self.args['prefix']:
            self.prefix_info.append(keywords.get(prefix, ''))

        # remove empty strings resulted from unexusting keys
        self.prefix_info = filter(len, map(str, self.prefix_info))
        prefix = ', '.join(self.prefix_info)

        for suffix in self.args['suffix']:
            self.suffix_info.append(keywords.get(suffix, ''))

        self.suffix_info = filter(len, map(str, self.suffix_info))
        suffix = ', '.join(self.suffix_info)

        # prevent list mutation
        self.prefix_info = list()
        self.suffix_info = list()

        return '({}) {} ({})'.format(prefix,
                                     running_test.test.__dict__['test'].__doc__,
                                     suffix)

    def options(self, parser, env=os.environ):
        super(DocString, self).options(parser, env)

        parser.add_option(
            '--prefix', default='id,platform',
            help='Append to this flag list of attributes you want to be printed'
                 'before the original docstring')
        parser.add_option(
            '--suffix', default='section,type,module',
            help='Append to this flag list of attributes you want to be printed'
                 'after the original docstring')
<commit_msg>Removed redundant class members, added --replace option - NOT IMPLEMENTED YET<commit_after>__author__ = 'maroun'


import os

from nose.plugins import Plugin


class DocString(Plugin):
    """
    This plugin enables you to display attributes next to the original
    docstring.

    Usage example:
         > python main.py --with-docstring --prefix=platform,id --suffix=type
    """

    args = dict()

    def describeTest(self, running_test):
        prefix_info = list()
        suffix_info = list()

        keywords = running_test.test.__dict__['test'].keywords

        for prefix in self.args['prefix']:
            prefix_info.append(keywords.get(prefix, ''))

        # remove empty strings resulted from unexusting keys
        prefix_info = filter(len, map(str, prefix_info))
        prefix = ', '.join(prefix_info)

        for suffix in self.args['suffix']:
            suffix_info.append(keywords.get(suffix, ''))

        suffix_info = filter(len, map(str, suffix_info))
        suffix = ', '.join(suffix_info)

        return '({}) {} ({})'.format(prefix,
                                     running_test.test.__dict__['test'].__doc__,
                                     suffix)

    def options(self, parser, env=os.environ):
        super(DocString, self).options(parser, env)

        parser.add_option(
            '--prefix', default='id,platform',
            help='Append to this flag list of attributes you want to be printed'
                 'before the original docstring, separated by COMMA')
        parser.add_option(
            '--suffix', default='section,type,module',
            help='Append to this flag list of attributes you want to be printed'
                 'after the original docstring, separated by COMMA')
        parser.add_option(
            '--replace',
            help='Replace characters in original docstring, for example:'
                 '--replace(a, A)'
        )

{'fraction_non_alphanumeric': 0.11117092866756394, 'fraction_numerical': 0.0, 'mean_word_length': 2.1815068493150687, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7642274', 'n_tokens_mistral': 1021, 'n_tokens_neox': 966, 'n_words': 269}