<commit_before>import argparse
import re

from argparse import *


class ToggleAction(argparse.Action):
    def __init__(self, option_strings, dest, default=False, required=False,
                 help=None):
        self.true_strings = [self._prefix(i, self._true_prefix)
                             for i in option_strings]
        self.false_strings = [self._prefix(i, self._false_prefix)
                              for i in option_strings]

        if default:
            option_strings = self.false_strings + self.true_strings
        else:
            option_strings = self.true_strings + self.false_strings

        argparse.Action.__init__(self, option_strings, dest=dest, nargs=0,
                                 default=default, required=required, help=help)

    def __call__(self, parser, namespace, values, option_string=None):
        value = option_string in self.true_strings
        setattr(namespace, self.dest, value)

    @staticmethod
    def _prefix(s, prefix):
        if s.startswith('--'):
            raise ValueError('option string must begin with "--"')
        return re.sub('(^--(x-)?)', r'\1' + prefix, s)


class EnableAction(ToggleAction):
    _true_prefix = 'enable-'
    _false_prefix = 'disable-'

<commit_msg>Fix check for toggle arguments' prefix<commit_after>import argparse
import re

from argparse import *


class ToggleAction(argparse.Action):
    def __init__(self, option_strings, dest, default=False, required=False,
                 help=None):
        self.true_strings = [self._prefix(i, self._true_prefix)
                             for i in option_strings]
        self.false_strings = [self._prefix(i, self._false_prefix)
                              for i in option_strings]

        if default:
            option_strings = self.false_strings + self.true_strings
        else:
            option_strings = self.true_strings + self.false_strings

        argparse.Action.__init__(self, option_strings, dest=dest, nargs=0,
                                 default=default, required=required, help=help)

    def __call__(self, parser, namespace, values, option_string=None):
        value = option_string in self.true_strings
        setattr(namespace, self.dest, value)

    @staticmethod
    def _prefix(s, prefix):
        if not s.startswith('--'):
            raise ValueError('option string must begin with "--"')
        return re.sub('(^--(x-)?)', r'\1' + prefix, s)


class EnableAction(ToggleAction):
    _true_prefix = 'enable-'
    _false_prefix = 'disable-'


{'fraction_non_alphanumeric': 0.102250296091591, 'fraction_numerical': 0.0015791551519936833, 'mean_word_length': 2.374167776298269, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7120244', 'n_tokens_mistral': 714, 'n_tokens_neox': 696, 'n_words': 170}