<commit_before>import string
import textwrap
from veryprettytable import VeryPrettyTable
from plugins import BasePlugin

__author__ = 'peter'


class BasicInfoPlugin(BasePlugin):
    name = 'BasicInfoPlugin'
    short_description = 'Basic info:'
    default = True
    description = textwrap.dedent('''
    This plugin provides some basic info about the string such as:
    - Length
    - Presence of alpha/digits/raw bytes
    ''')

    def handle(self):
        result = ''
        for s in self.args['STRING']:
            if len(self.args['STRING']) > 1:
                result += '{0}:\n'.format(s)
            table = VeryPrettyTable()
            table.field_names = ['Length', '# Digits', '# Alpha', '# unprintable']
            table.add_row((len(s), sum(x.isdigit() for x in s), sum(x.isalpha() for x in s),
                           sum(x in string.printable for x in s)))
            result += str(table) + '\n'

        return result<commit_msg>Add punctuation to basic info<commit_after>import string
import textwrap
from veryprettytable import VeryPrettyTable
from plugins import BasePlugin

__author__ = 'peter'


class BasicInfoPlugin(BasePlugin):
    name = 'BasicInfoPlugin'
    short_description = 'Basic info:'
    default = True
    description = textwrap.dedent('''
    This plugin provides some basic info about the string such as:
    - Length
    - Presence of alpha/digits/raw bytes
    ''')

    def handle(self):
        result = ''
        for s in self.args['STRING']:
            if len(self.args['STRING']) > 1:
                result += '{0}:\n'.format(s)
            table = VeryPrettyTable()
            table.field_names = ['Length', '# Digits', '# Alpha', '# Punct.', '# Control']
            table.add_row((len(s), sum(x.isdigit() for x in s), sum(x.isalpha() for x in s),
                           sum(x in string.punctuation for x in s), sum(x not in string.printable for x in s)))
            result += str(table) + '\n'

        return result
{'fraction_non_alphanumeric': 0.12128837443381983, 'fraction_numerical': 0.0020130850528434826, 'mean_word_length': 2.398290598290598, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1180995', 'n_tokens_mistral': 581, 'n_tokens_neox': 564, 'n_words': 178}